- Nodejs: Runtime Environment
- Express: Web framework
- Socket.io: Socket library
- Redis (for scalability): pub/sub events and socket ids between the instances.
- MongoDB: Message store
- Postman docs: https://documenter.getpostman.com/view/4640091/TVmJgdx7
-
Handshake:
-
Namespace: /v1/conversations/events
-
Path: /v1/conversations/sockets
-
Query:
token
user_id
user_role
: BUYER / SELLER
-
Example:
let socket = io('https://api.chozoi.com/v1/conversations/events', { path: '/v1/conversations/sockets', transports: ['websocket'], query: { token: 'access_token', user_id: 'user_id', user_role: 'BUYER' }});
-
-
Events:
-
create_room
:-
client:
type
: Room type. Value: BSbuyer
: Buyer IDseller
: Seller IDshop_id
: Shop IDcreator
: Buyer ID or Seller ID
-
server:
room_id
: Room ID. Value: <BuyerID>.<SellerID>type
: Room type. Value: BSbuyer
: Buyer IDseller
: Seller IDshop_id
: Shop IDcreator
: Buyer ID or Seller ID
-
-
new_message
:-
client:
room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver IDtype
: TEXT | IMAGE | EMOJIcontent
: Message contentclient_message_id
: (optional) Client generator unique id for server to comfirm
-
server:
_id
: Message Id generated by server.room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver IDtype
: TEXT | IMAGE | EMOJIcontent
: Message contentclient_message_id
: (optional) Client generator unique id for server to comfirmcreated_at
: Created time
-
-
room_deletion
:- server:
room_id
seller
buyer
deletion_role
: SELLER | BUYER. Who deleted room.
- server:
-
typing
:- client:
room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver ID
- server:
room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver ID
- client:
-
stop_typing
:- client:
room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver ID
- server:
room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver ID
- client:
-
seen_messages
:-
client:
room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver IDlast_message_id
: ID of the last messagelast_message_created_at
: the created time of the last message
-
server:
room_id
: Room ID. Value: <BuyerID>.<SellerID>from
: Sender IDto
: Receiver IDlast_message_id
: ID of the last messagelast_message_created_at
: the created time of the last message
-
-
active_user_list
: get list of active users- server:
user_id
user_role
rooms
: Arrayroom_id
status
: Boolean
- server:
-
user_status_change
:- server:
user_id
user_role
room_id
status
: Boolean
- server:
-
reconnect
:- client: emit event
verify_user
:token
user_id
user_role
: BUYER / SELLER
- client: emit event
-
verify_user
:- client:
token
user_id
user_role
: BUYER / SELLER
- server:
status
: boolean
- client:
-
-
Socket.io
- Server: https://socket.io/docs/server-api/
- Client: https://socket.io/docs/client-api/
-
Kafka