public class Socket extends Emitter
Modifier and Type | Class and Description |
---|---|
static class |
Socket.Options |
Emitter.Listener
Modifier and Type | Field and Description |
---|---|
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_PING |
static String |
EVENT_PONG |
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 int |
PROTOCOL
The protocol version.
|
Constructor and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
Socket |
close()
Disconnects the client.
|
String |
id() |
Socket |
open()
Connects the client.
|
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 |
setDefaultOkHttpCallFactory(okhttp3.Call.Factory factory) |
static void |
setDefaultOkHttpWebSocketFactory(okhttp3.WebSocket.Factory factory) |
void |
write(byte[] msg) |
void |
write(byte[] msg,
Runnable fn) |
void |
write(String msg) |
void |
write(String msg,
Runnable fn) |
public static final String EVENT_OPEN
public static final String EVENT_CLOSE
public static final String EVENT_MESSAGE
public static final String EVENT_ERROR
public static final String EVENT_UPGRADE_ERROR
public static final String EVENT_FLUSH
public static final String EVENT_DRAIN
public static final String EVENT_HANDSHAKE
public static final String EVENT_UPGRADING
public static final String EVENT_UPGRADE
public static final String EVENT_PACKET
public static final String EVENT_PACKET_CREATE
public static final String EVENT_HEARTBEAT
public static final String EVENT_DATA
public static final String EVENT_PING
public static final String EVENT_PONG
public static final String EVENT_TRANSPORT
public static final int PROTOCOL
public Socket()
public Socket(String uri) throws URISyntaxException
uri
- URI to connect.URISyntaxException
public Socket(URI uri)
public Socket(String uri, Socket.Options opts) throws URISyntaxException
uri
- URI to connect.opts
- options for socketURISyntaxException
public Socket(URI uri, Socket.Options opts)
public Socket(Socket.Options opts)
public static void setDefaultOkHttpWebSocketFactory(okhttp3.WebSocket.Factory factory)
public static void setDefaultOkHttpCallFactory(okhttp3.Call.Factory factory)
public Socket open()
public void write(String msg)
public void write(byte[] msg)
public void write(byte[] msg, Runnable fn)
public void send(String msg)
msg
- public void send(byte[] msg)
public void send(String msg, Runnable fn)
msg
- fn
- callback to be called on drainpublic void send(byte[] msg, Runnable fn)
public Socket close()
public String id()
Copyright © 2022. All rights reserved.