public interface ServerSocket extends AbstractServerSocket<ServerSocket>
ServerSocket
produced by Server
is used to send and receive
event to and from the remote socket. The normal usage to use
ServerSocket
is to create a socket action and pass it to
Server
. If you are going to hold a reference on ServerSocket
,
you should do something when it is closed through
onclose(Action)
.
Sockets may be accessed by multiple threads.
Modifier and Type | Interface and Description |
---|---|
static interface |
ServerSocket.Reply<T>
Interface to deal with reply.
|
Modifier and Type | Method and Description |
---|---|
<T> ServerSocket |
off(String event,
io.cettia.platform.action.Action<T> action)
Removes a given event handler for a given event.
|
<T> ServerSocket |
on(String event,
io.cettia.platform.action.Action<T> action)
Adds a given event handler for a given event.
|
ServerSocket |
onclose(io.cettia.platform.action.Action<Void> action)
Executed if the socket is closed for any reason.
|
ServerSocket |
onerror(io.cettia.platform.action.Action<Throwable> action)
Executed if there was any error on the socket.
|
<T> ServerSocket |
send(String event,
Object data,
io.cettia.platform.action.Action<T> resolved)
Sends a given event with data attaching resolved callback.
|
<T,U> ServerSocket |
send(String event,
Object data,
io.cettia.platform.action.Action<T> resolved,
io.cettia.platform.action.Action<U> rejected)
Sends a given event with data attaching resolved callback and rejected
callback.
|
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.
|
<T> ServerSocket on(String event, io.cettia.platform.action.Action<T> action)
The allowed types for T
are Java types corresponding to JSON
types.
JSON | Java |
---|---|
Number | Integer or Double |
String | String |
Boolean | Boolean |
Array | List , List<T> in generic |
Object | Map , Map<String, T> in generic |
null | null , Void for convenience |
T
should be
ServerSocket.Reply
.ServerSocket onclose(io.cettia.platform.action.Action<Void> action)
socket.on("close", action)
ServerSocket onerror(io.cettia.platform.action.Action<Throwable> action)
error
event. Equivalent to
socket.on("error", action)
<T> ServerSocket off(String event, io.cettia.platform.action.Action<T> action)
<T> ServerSocket send(String event, Object data, io.cettia.platform.action.Action<T> resolved)
For the allowed types for T
, see
on(String, Action)
.
<T,U> ServerSocket send(String event, Object data, io.cettia.platform.action.Action<T> resolved, io.cettia.platform.action.Action<U> rejected)
For the allowed types for T
, see
on(String, Action)
.
<T> T unwrap(Class<T> clazz)
ServerTransport
is available.Copyright 2015, The Cettia Project