Java Reference
In-Depth Information
instance, whereas the synchronous method returns a RemoteEndpoint.Basic . These
both implement the RemoteEndpoint interface, as defined in the next listing.
Listing 14.8. RemoteEndpoint interface
Although we won't go into detail about each method, the asynchronous interface and
the synchronous interface have the same basic capabilities. Both can send text as well
as raw bytes and Java objects. When sending Java objects, the encoders registered on an
endpoint will be used to convert the Java object into a representation that will be transmit-
ted via a WebSocket.
The code in ActionBazaar using the asynchronous interface for sending out messages is as
follows:
ChatMessage cm = new ChatMessage(username,message);
csrSession.getAsyncRemote().sendObject(cm);
Search WWH ::




Custom Search