Closed ghost closed 14 years ago
You need to call send(String)
on an individual WebSocket
instance to send an individual message. These are retrieved as the first parameter from any of the onOpen
, onClose
or onMessage
callbacks, or via the connections
property on the WebSocketServer
instance.
Perhaps it would be helpful to add a convenience function to the WebSocketServer
class: send(WebSocket, String)
?
I urge you to look at the precompiled JavaDoc files inside the doc
folder inside the repo for any more API questions.
Hey,
Thanks for your reply. Yes, I get a WebSocket object every time onClientOpen(conn) gets called. I then copy this object and can send to an individual browser. It's all working now. Sorry for the schoolboy error. I'm just back to Java after many years of programming in C.
Good project. So much cleaner and more straightforward than jWebSocket which has a crazy website. You provide one jar for the WebSocket server and one jar for the javadocs. Perfect.
I'm looking at the ChatServer.java example
I see how you can send a message to all web clients using the sendToAll(String) function, but how does one send to just a single web client?
It's not coming up in my Eclipse autocomplete.
Many thanks in advance,