New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Channel message dispatching issue #182
Comments
Please excuse my late answer. Yes, you have total control which client will see which messages - you write the server - you have control over all connections. Via onMessage you know which client sent which messages to the server. Based on that information you can decide to which client you "forward" it ( by calling WebSocket.send ) You can iterate through the connected clients by iterating over WebSocketServer.connections() in synchronized manner. Like this: Collection<WebSocket> con = connections();
synchronized ( con ) {
for( WebSocket c : con ) {
// put your special condition here
c.send( "text" );
}
} Currently its not very comfortable to obtain the resource descriptor ( "/news"). One has to make use of a WebSocketFactory and deriving from WebSocketImpl to create a function that returns the resource descriptor... Since i think that what you ask for is a rather common case i will add a getResourceDescriptor() method to the WebSocket class which allows you to easily find out which resource descriptor was used the in websocket handshake. Feel free to ask if you have further questions. |
getResourceDescriptor do the WebSocket interface. #182
After pulling you should be able to do something like this: Collection<WebSocket> con = connections();
synchronized ( con ) {
for( WebSocket c : con ) {
if( c.getResourceDescriptor().equals("/news") )
c.send( "this is new" );
}
} |
Awesome man looks pretty good, thanks so much |
Hi,
First at all, great component, was doing some tests with multiple clients but noticed some things for example, if some clients are connected to ws://x.x.x.x:8090/news and there are another clients connected to ws://x.x.x.x:8090/actions, all the clients will listen the same messages, so my question is, is there any way to isolate both group of clients, so group of news can listen only news and so on with actions group,
Thanks,
The text was updated successfully, but these errors were encountered: