public interface ServerSocket extends AbstractServerSocket<ServerSocket>, org.atmosphere.vibe.platform.Wrapper
ServerSocket
is a connectivity between the two vibe endpoints.
Do not hold a reference on ServerSocket
unless the reference shares
the same life cycle with it. It makes things complicated since it is stateful
and also may result in a problem in clustered environment. Always create a
socket action and pass it to Server
to access ServerSocket
.
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 |
---|---|
ServerSocket |
closeAction(org.atmosphere.vibe.platform.Action<Void> action)
Equivalent to
socket.on("close", action) |
ServerSocket |
errorAction(org.atmosphere.vibe.platform.Action<Throwable> action)
Equivalent to
socket.on("error", action) |
String |
id()
A unique identifier in the form of UUID generated by client by default.
|
<T> ServerSocket |
off(String event,
org.atmosphere.vibe.platform.Action<T> action)
Removes a given added event handler for a given event.
|
<T> ServerSocket |
on(String event,
org.atmosphere.vibe.platform.Action<T> action)
Adds a given event handler for a given event.
|
<T> ServerSocket |
send(String event,
Object data,
org.atmosphere.vibe.platform.Action<T> resolved)
Sends a given event with data attaching resolved callback.
|
<T,U> ServerSocket |
send(String event,
Object data,
org.atmosphere.vibe.platform.Action<T> resolved,
org.atmosphere.vibe.platform.Action<U> rejected)
Sends a given event with data attaching resolved callback
and rejected callback.
|
Set<String> |
tags()
A set of tag names.
|
String |
uri()
A URI used to connect.
|
String id()
<T> ServerSocket on(String event, org.atmosphere.vibe.platform.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 closeAction(org.atmosphere.vibe.platform.Action<Void> action)
socket.on("close", action)
ServerSocket errorAction(org.atmosphere.vibe.platform.Action<Throwable> action)
socket.on("error", action)
<T> ServerSocket off(String event, org.atmosphere.vibe.platform.Action<T> action)
<T> ServerSocket send(String event, Object data, org.atmosphere.vibe.platform.Action<T> resolved)
For the allowed types for T
, see
on(String, Action)
.
<T,U> ServerSocket send(String event, Object data, org.atmosphere.vibe.platform.Action<T> resolved, org.atmosphere.vibe.platform.Action<U> rejected)
For the allowed types for T
, see
on(String, Action)
.
Copyright 2014, The Vibe Project