Class WebSocketImpl

java.lang.Object
com.codename1.impl.WebSocketImpl

public abstract class WebSocketImpl extends Object

Platform contract behind the public com.codename1.io.WebSocket facade. Each port that supports WebSocket subclasses this and is returned from CodenameOneImplementation.createWebSocketImpl(String).

Subclasses call sink().onConnect(), sink().onTextMessage(...), etc. from whichever thread the native layer fires the event on. The sink is set exactly once, by the facade, before connect(int) is called.

  • Constructor Details

    • WebSocketImpl

      protected WebSocketImpl(String url)
  • Method Details

    • getUrl

      public final String getUrl()
    • setEventSink

      public final void setEventSink(WebSocketEventSink sink)
    • sink

      protected final WebSocketEventSink sink()
    • connect

      public abstract void connect(int connectTimeoutMs)
      Initiate the connection. May return immediately and complete asynchronously; success is signalled via sink().onConnect().
      Parameters:
      connectTimeoutMs - handshake timeout in milliseconds, or 0 for the platform default.
    • close

      public abstract void close()
      Close the connection. Idempotent -- calling on an already-closed connection is a no-op.
    • sendText

      public abstract void sendText(String message)
    • sendBinary

      public abstract void sendBinary(byte[] message)
    • getReadyState

      public abstract WebSocketState getReadyState()