public interface Socket
Socket
is a connectivity between the two portal endpoints.
Do not hold a reference on Socket
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 Socket
.
Sockets may be accessed by multiple threads.
Modifier and Type | Interface and Description |
---|---|
static interface |
Socket.Reply<T>
Interface to deal with reply.
|
Modifier and Type | Method and Description |
---|---|
Socket |
close()
Closes the session.
|
String |
id()
A unique identifier in the form of UUID generated by client by default.
|
<T> Socket |
off(String event,
Action<T> action)
Removes a given added event handler for a given event.
|
<T> Socket |
on(String event,
Action<T> action)
Adds a given event handler for a given event.
|
Socket |
send(String event)
Sends a given event without data.
|
Socket |
send(String event,
Object data)
Sends a given event with data.
|
<T> Socket |
send(String event,
Object data,
Action<T> reply)
Sends a given event with data registering callback.
|
Set<String> |
tags()
A set of tag names.
|
String |
uri()
A URI used to connect.
|
<T> Socket 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 Socket.Reply
.<T> Socket off(String event, Action<T> action)
<T> Socket send(String event, Object data, Action<T> reply)
For the allowed types for T
, see on(String, Action)
.
Copyright 2012-2014, Donghwan Kim