Migrate WebSocket and ByteSocket Applications to Kaazing Java SDK 4.x
This topic covers the issues involved in migrating Kaazing Gateway 3.2-3.5 Java clients built using the ByteSocket API to the Java API in Kaazing Java SDK 4.x. Kaazing Java SDK 4.x no longer includes the ByteSocket API because the WebSocket and WsURLConnection classes in the Kaazing Java SDK 4.x Java library support binary messaging.
For more information about the Kaazing Java 4.x API, see Interact with Kaazing Gateway Using the WebSocket API and Java Client API.
Before You Begin
This procedure is part of Checklist: Build Java WebSocket Clients.
Note: Learn about supported browsers, operating systems, and platform versions in the Release Notes.
Legacy Client Support
Kaazing Java WebSocket Client 4.x supports Java clients written using the Kaazing Gateway 3.2-3.5 Java APIs. You do not need to migrate your legacy Java client to use Kaazing Java SDK 4.x. If you wish to take advantage of the new Java API for Kaazing Java WebSocket Client 4.x or new features of Kaazing Java WebSocket Client 4.x, you must migrate your Java client.
The new Java API for Kaazing Java WebSocket Client 4.x is easier to use than previous versions, but it does require that you change your Kaazing Gateway 3.2-3.5 Java API client code to take advantage of it.
Binary Support in the Kaazing Java WebSocket Client 4.x API
Both WebSocket and WsURLConnection classes support APIs that enable use the use of byte-based data streams as they define java.io.InputStream and java.io.OutoutStream methods. getInputStream() is used for receiving binary streams and getOutputStream() is used to sending binary streams. If either method is used to receive text messages, or the methods are invoked before a connection is made, then an IOException is thrown. Once the connection is closed, a new InputStream or OutputStream should be obtained using these methods after the connection has been established. Using the old InputStream or OutputStream will result in IOException.
For information and example, see Interact with Kaazing Gateway Using the WebSocket API.
Blocking Calls and ByteSocketListener
The ByteSocketListener interface in the Kaazing Gateway - HTML5 Edition 3.x Java WebSocket API is not included in the Java WebSocket API for Kaazing Java WebSocket Client 4.x.
WebSocket.ReadyState and ByteSocket.ReadyState No Longer Used in the Java WebSocket API
The WebSocket.ReadyState class in the Java WebSocket API in Kaazing Gateway - HTML5 Edition 3.x is not included in the Java WebSocket API for Kaazing Java WebSocket Client 4.x.
The Java WebSocket API for Kaazing Java WebSocket Client 4.x supports blocking for the connect() and close() methods and eliminates the need for the WebSocket.ReadyState and ByteSocket.ReadyState.
Similarly, the InputStream, Reader, and WebSocketMessageReader support blocking calls that eliminate the need for MessageEvent as the control will come out of the blocking call only when the message has arrived.