---
# System prepended metadata

title: Instalent socket workflow
tags: [Documentation]

---

# Instalent socket workflow

###### tags: `Documentation`

#### Data in request:

```javascript=16
const payload = {
    "request_user_id": "1",
    "service_id": "1",
    "city_id": "1",
    "full_address": "Da Nang",
    "booking_time": "2016-06-22 19:10:25-07",
    "time_range": "3.5"
}
```

- Sequence for booking
```sequence
Client->Socket Server: Init connection with header token
Socket Server-->Client: response connection status
ServiceProvider->Socket Server: Init connection
Socket Server-->ServiceProvider: response connection status
Client->Client: Booking action
Client-> Socket Server: socket.emit('BOOKING_REQUEST', payload, callback)
Socket Server-->Client: callback
Client->Client: Update booking status to Booked
Socket Server-->Socket Server: Find 5 service provider\nmatching with request
Socket Server->ServiceProvider: socket.to('profileId')\n.emit('NEW_BOOKING_REQUEST', data, callback)
ServiceProvider-->Socket Server: emit event to Socket Setver\nACCEPT|CANCEL|NOT_RESPONSE
Socket Server-->Socket Server: Check response from Service Provider\nIf not ACCEPt will call to next user\n
Socket Server->Client: socket.emit('BOOKING_SUCCESS', payload)
```


```javascript=16
const payloadMsg = {
    "conversation_id": "conversationId",
    "profile_id": "1",
    "message": {
       "type": "text",
       "content": "hello"
    }
}

const payloadTypingOrSeen = {
  "conversation_id": "conversationId",
  "profile_id": "1",
}
```

- Sequence for chating
```sequence

Client->Socket: socket.emit(JOIN_ROOM_REQUEST, conversationId)
Socket-->Client: socket.emit(JOIN_ROOM_SUCCESSED)

ServiceProvider->Socket: socket.emit(JOIN_ROOM_REQUEST, conversationId)
Socket-->ServiceProvider: socket.emit(JOIN_ROOM_SUCCESSED)
Client->Socket: socket.emit(SEND_MESSAGE_REQUEST, payloadMsg)
Socket-->Client: socket.emit(NEW_MESSAGE, payloadMsg)
Socket->ServiceProvider: socket.emit(NEW_MESSAGE, payloadMsg)
Client->Socket: socket.emit(TYPING_MESSAGE, payloadTypingOrSeen)
Socket->ServiceProvider: socket.emit(TYPING_MESSAGE, payloadTypingOrSeen)
ServiceProvider->Socket: socket.emit(MESSAGE_SEEN, payloadTypingOrSeen)
Socket->Client: socket.emit(MESSAGE_SEEN, payloadTypingOrSeen)
Client->Socket: socket.emit(LEAVE_ROOM_REQUEST, conversationId)
Socket-->Client: socket.emit(LEAVE_ROOM_SUCCESSED)
```