Dear all, I have some client that they register themselves via SocketConnection with username as unique key. At server side i want to send a message to all client whom register themselves as said above. In PureServerUtilsFE.clientSocketFE i did not find this method.
For your requirement, to broadcast any message to all clients, you can use the broadcastToAllClients() method. Here you need to use the id "BROADCAST_FROM_CLIENT".
In the "message" to be broadcasted you need to set the "type". The type can be FECLIENTS or ALLCLIENTS according to your requirement. (FECLIENTS - to broadcast to only the clients connected with this FE. ALLCLIENTS - to broadcast to all clients connected to BE.)
You can use the following code-snippet:
String message = "This is my message to client"; ByteArrayOutputStream byteStream=new ByteArrayOutputStream(); DataOutputStream outp=new DataOutputStream(byteStream); outp.writeInt(97); // this int is to indicate that it is a broadcast info. outp.writeUTF(message); outp.writeUTF("ALLCLIENTS"); outp.flush(); PureServerUtilsBE.specialSessionBE.broadcastToAllClients("BROADCAST_FROM_CLIENT","0",byteStream.toByteArray());
If you have a BroadcastClient listener registered, then the receive method of this class will be invoked when the message is broadcasted. You can also refer to the javadocs of BroadcastClient from the below link:
Dear Thiyag, I don't want to show the popup message to clients, but i want to get the message and do some jobs at client side. i used registerForResponse(BroadcastListener bl) method and in receiveAndShow get the messages but they also shown via a popup. How can i send a broadcast message just to do some jobs at client side and do not show it as popup?
I found it. i use: PureServerUtilsFE.clientSocketFE.broadcastMessage("message"); so client which register themselves via SocketConnection get the message.
thanks.
Leave a comment on javageek's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic