Django, socket.io, node.js - Manage private messages and group conversations -


i in process of writing back-end service such facebook messenger or whatsapp.

i started out following splendid tutorial.

i api written in python (django). along side api, have redis process , node.js server running (localhost only). node.js server uses socket.io library real-time communication through websockets

an http-request containing message can sent client django api, in turn publishes message redis on channel.

the node.js server has subscribed redis channel, , gets notified when such message published. node keeps track of sockets connected array of socket ids keyed user identifier.

i have few questions this:

1. private messages

i send message targeted user. initial approach have http-request (sent django) include user message should reach. when message reaches node.js server (through redis), node can find user in array of clients. django obviously(?) needs know socket.io socket belongs user. i.e. django needs know user identifying key node should use grab right socket.

is approach? redis-server bottleneck since use 1 publishing channel? happens if target user of message offline when source user sends message? grab event , send push-notification.

2. rooms

this service wouldn't if there not functionality starting , maintaining group conversations. have read, should create socket.io:s rooms this. question then, how maintain room between sessions? if every user participating in group conversation goes offline , thereby removed node.js server:s array of clients. can somehow store rooms between sessions in django server?.

any and/or feedback/thoughts appreciated. thanks

  1. private messages

node keeps track of sockets connected array of socket ids keyed user identifier.

you pretty said there. django not need know socket id of target user, node.js does. if want send message user 3 sent message + target user (or other meta data want) redis. node.js user reading element id 3 socket array , send message connection. if there no element id = 3, user offline , can send push notification. eather in node.js or notifying django server.

  1. rooms

since want rooms persistant should store them in kind of database mysql or mongodb. node.js server create rooms , if user connects can in rooms participated using user id. if join new room have update database. if new room created, node.js needs create socket.io room , database needs updated well.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -