views:

38

answers:

3

Greets to all! I want to create private messaging based on websockets. It is possible to implement session between two users using websockets?

A: 

I think that in order to do this, you will need to obtain the users' IP addresses and open the destination ports on each. Doing this should be impossible, given that the sockets should handshake (and you don't have access to the handshake process).

Alexander Gyoshev
A: 

You can't do this directly between two browsers. The WebSockets spec does not specify a way to listen for incoming connections to the browser, only outgoing connections. You need some sort of WebSockets endpoint that both browsers can initiate connections to.

kanaka
+1  A: 

Yes

WS connections go through a central server and as such it is impossible to bypass that and make a direct connection to two users. You can on the server facilitate communication between two users though. You would have to have the users either preselected or make some sort of "join" action, possibly from a group list of logged in users. Then your application would manage a "private" sort of chat between the two, essentially an instance of the main chat except users aren't added automatically but rather by intent.

Josh K