com.github.nkzawa.engineio.client
Class Socket

java.lang.Object
  extended by com.github.nkzawa.emitter.Emitter
      extended by com.github.nkzawa.engineio.client.Socket

public class Socket
extends Emitter

The socket class for Event.IO Client.

See Also:
https://github.com/LearnBoost/engine.io-client

Nested Class Summary
static class Socket.Options
           
 
Nested classes/interfaces inherited from class com.github.nkzawa.emitter.Emitter
Emitter.Listener
 
Field Summary
static String EVENT_CLOSE
          Called on disconnection.
static String EVENT_DATA
           
static String EVENT_DRAIN
          Called after `drain` event of transport if writeBuffer is empty.
static String EVENT_ERROR
          Called when an error occurs.
static String EVENT_FLUSH
          Called on completing a buffer flush.
static String EVENT_HANDSHAKE
           
static String EVENT_HEARTBEAT
           
static String EVENT_MESSAGE
          Called when data is received from the server.
static String EVENT_OPEN
          Called on successful connection.
static String EVENT_PACKET
           
static String EVENT_PACKET_CREATE
           
static String EVENT_TRANSPORT
          Called on a new transport is created.
static String EVENT_UPGRADE
           
static String EVENT_UPGRADE_ERROR
           
static String EVENT_UPGRADING
           
static boolean priorWebsocketSuccess
           
static int protocol
          The protocol version.
 
Constructor Summary
Socket()
           
Socket(Socket.Options opts)
           
Socket(String uri)
          Creates a socket.
Socket(String uri, Socket.Options opts)
          Creates a socket with options.
Socket(URI uri)
           
Socket(URI uri, Socket.Options opts)
           
 
Method Summary
 Socket close()
          Disconnects the client.
 Socket open()
          Connects the client.
 void ping()
          Sends a ping packet.
 void send(byte[] msg)
           
 void send(byte[] msg, Runnable fn)
           
 void send(String msg)
          Sends a message.
 void send(String msg, Runnable fn)
          Sends a message.
static void setDefaultSSLContext(SSLContext sslContext)
           
 void write(byte[] msg)
           
 void write(byte[] msg, Runnable fn)
           
 void write(String msg)
           
 void write(String msg, Runnable fn)
           
 
Methods inherited from class com.github.nkzawa.emitter.Emitter
emit, hasListeners, listeners, off, off, off, on, once
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT_OPEN

public static final String EVENT_OPEN
Called on successful connection.

See Also:
Constant Field Values

EVENT_CLOSE

public static final String EVENT_CLOSE
Called on disconnection.

See Also:
Constant Field Values

EVENT_MESSAGE

public static final String EVENT_MESSAGE
Called when data is received from the server.

See Also:
Constant Field Values

EVENT_ERROR

public static final String EVENT_ERROR
Called when an error occurs.

See Also:
Constant Field Values

EVENT_UPGRADE_ERROR

public static final String EVENT_UPGRADE_ERROR
See Also:
Constant Field Values

EVENT_FLUSH

public static final String EVENT_FLUSH
Called on completing a buffer flush.

See Also:
Constant Field Values

EVENT_DRAIN

public static final String EVENT_DRAIN
Called after `drain` event of transport if writeBuffer is empty.

See Also:
Constant Field Values

EVENT_HANDSHAKE

public static final String EVENT_HANDSHAKE
See Also:
Constant Field Values

EVENT_UPGRADING

public static final String EVENT_UPGRADING
See Also:
Constant Field Values

EVENT_UPGRADE

public static final String EVENT_UPGRADE
See Also:
Constant Field Values

EVENT_PACKET

public static final String EVENT_PACKET
See Also:
Constant Field Values

EVENT_PACKET_CREATE

public static final String EVENT_PACKET_CREATE
See Also:
Constant Field Values

EVENT_HEARTBEAT

public static final String EVENT_HEARTBEAT
See Also:
Constant Field Values

EVENT_DATA

public static final String EVENT_DATA
See Also:
Constant Field Values

EVENT_TRANSPORT

public static final String EVENT_TRANSPORT
Called on a new transport is created.

See Also:
Constant Field Values

protocol

public static final int protocol
The protocol version.

See Also:
Constant Field Values

priorWebsocketSuccess

public static boolean priorWebsocketSuccess
Constructor Detail

Socket

public Socket()

Socket

public Socket(String uri)
       throws URISyntaxException
Creates a socket.

Parameters:
uri - URI to connect.
Throws:
URISyntaxException

Socket

public Socket(URI uri)

Socket

public Socket(String uri,
              Socket.Options opts)
       throws URISyntaxException
Creates a socket with options.

Parameters:
uri - URI to connect.
opts - options for socket
Throws:
URISyntaxException

Socket

public Socket(URI uri,
              Socket.Options opts)

Socket

public Socket(Socket.Options opts)
Method Detail

setDefaultSSLContext

public static void setDefaultSSLContext(SSLContext sslContext)

open

public Socket open()
Connects the client.

Returns:
a reference to to this object.

ping

public void ping()
Sends a ping packet.


write

public void write(String msg)

write

public void write(String msg,
                  Runnable fn)

write

public void write(byte[] msg)

write

public void write(byte[] msg,
                  Runnable fn)

send

public void send(String msg)
Sends a message.

Parameters:
msg -

send

public void send(byte[] msg)

send

public void send(String msg,
                 Runnable fn)
Sends a message.

Parameters:
msg -
fn - callback to be called on drain

send

public void send(byte[] msg,
                 Runnable fn)

close

public Socket close()
Disconnects the client.

Returns:
a reference to to this object.


Copyright © 2014. All rights reserved.