public interface ServerSocket extends AbstractServerSocket<ServerSocket>, org.atmosphere.vibe.platform.Wrapper
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
closeAction(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 |
|---|---|
ServerSocket |
closeAction(org.atmosphere.vibe.platform.Action<Void> action)
Executed if the socket is closed for any reason.
|
ServerSocket |
errorAction(org.atmosphere.vibe.platform.Action<Throwable> action)
Executed if there was any error on the socket.
|
String |
id()
A unique identifier.
|
<T> ServerSocket |
off(String event,
org.atmosphere.vibe.platform.Action<T> action)
Removes a given 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 modifiable 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