public interface ServerSocket extends AbstractServerSocket<ServerSocket>, 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 |
|---|---|
String |
id()
A unique identifier in the form of UUID generated by client by default.
|
<T> ServerSocket |
off(String event,
Action<T> action)
Removes a given added event handler for a given event.
|
<T> ServerSocket |
on(String event,
Action<T> action)
Adds a given event handler for a given event.
|
<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.
|
Set<String> |
tags()
A set of tag names.
|
String |
uri()
A URI used to connect.
|
String id()
<T> ServerSocket on(String event, 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.<T> ServerSocket off(String event, Action<T> action)
<T> ServerSocket send(String event, Object data, Action<T> resolved)
For the allowed types for T, see
on(String, Action).
<T,U> ServerSocket send(String event, Object data, Action<T> resolved, Action<U> rejected)
For the allowed types for T, see
on(String, Action).
Copyright 2014, The Vibe Project