Java-based WebSocket Client/Listener using Tyrus

Here’s an example on building a Java-based websocket client or listener that listens to the stream of RSVP notifications from meetup.com at http://www.meetup.com/meetup_api/docs/stream/2/rsvps using Tyrus, a reference implementation of JSR 356, Java API for WebSocket.

Tyrus Websocket Implementation
Tyrus Websocket Implementation

Websocket

IETF defined WebSocket as a protocol to provide asynchronous, full-duplex and bi-directional communication/messaging between the server and the remote host over TCP connection. The advantages mainly are: the ability to communicate both ways, low latency and small communication overhead. It’s best suited for web applications that may need to send a huge volume of relatively small messages like stock market ticks.

Here’s an example :

You need to add couple of libraries to include tyrus websocket client libraries (version is 1.9 as of writing this) to get this example to work – Eg. using gradle:

Copy Protected by Chetan's WP-Copyprotect.