public interface ServerSocket extends AbstractServerSocket<ServerSocket>
Modifier and Type | Interface and Description |
---|---|
static interface |
ServerSocket.Reply<T>
Interface to deal with reply.
|
static class |
ServerSocket.State
Enumeration of the state of the socket.
|
Modifier and Type | Method and Description |
---|---|
<T> ServerSocket |
off(String event,
Action<T> action)
Removes a given event handler for a given event.
|
<T> ServerSocket |
on(String event,
Action<T> action)
Adds a given event handler for a given event.
|
ServerSocket |
oncache(Action<Object[]> action)
Adds a cache event handler to be called if one of
send methods is called when
there is no connection. |
ServerSocket |
onclose(Action<Void> action)
Adds a close event handler to be called when the underlying transport is closed for any reason.
|
ServerSocket |
ondelete(Action<Void> action)
Adds a delete event handler to be called when the socket is in the closed state for a long
time i.e.
|
ServerSocket |
onerror(Action<Throwable> action)
Adds an error event handler to be called if there was any error on the socket.
|
ServerSocket |
onopen(Action<Void> action)
Adds an open event handler to be called when the handshake is performed successfully and
communication is possible.
|
<T> ServerSocket |
send(String event,
Object data,
Action<T> resolved)
Sends a given event with data attaching resolved callback.
|
<T,U> ServerSocket |
send(String event,
Object data,
Action<T> resolved,
Action<U> rejected)
Sends a given event with data attaching resolved callback and rejected callback.
|
ServerSocket.State |
state()
The current state of the socket.
|
Set<String> |
tags()
A modifiable set of tag names.
|
<T> T |
unwrap(Class<T> clazz)
Returns the underlying component.
|
String |
uri()
A URI used to connect.
|
ServerSocket.State state()
<T> ServerSocket on(String event, Action<T> action)
T
is determined by a format which is used to deserialize
transport message. Now that format corresponds to
Jackson's data format. By default,
built-in data format is used for text message, and
MessagePack data
format is used for binary message.
If the counterpart sends an event with callback, T
should be
ServerSocket.Reply
.ServerSocket onopen(Action<Void> action)
socket.on("open", action)
ServerSocket onclose(Action<Void> action)
socket.on("close", action)
ServerSocket onerror(Action<Throwable> action)
socket.on("error", action)
ServerSocket oncache(Action<Object[]> action)
send
methods is called when
there is no connection. The given value is an array of arguments of
send(String, Object, Action, Action)
.
Equivalent to socket.on("cache", action)
ServerSocket ondelete(Action<Void> action)
delete
event is called only once.
Equivalent to socket.on("delete", action)
<T> ServerSocket off(String event, Action<T> action)
<T> ServerSocket send(String event, Object data, Action<T> resolved)
T
, see on(String, Action)
.<T,U> ServerSocket send(String event, Object data, Action<T> resolved, Action<U> rejected)
T
, see on(String, Action)
.<T> T unwrap(Class<T> clazz)
ServerTransport
is available.Copyright 2015, The Cettia Project