public class DefaultServer extends Object implements Server
Server.
This implementation provides and manages Socket processing HTTP
request and WebSocket following the portal protocol.
As options, the following methods can be overridden.
| Constructor and Description |
|---|
DefaultServer() |
| Modifier and Type | Method and Description |
|---|---|
Sentence |
all()
Returns a sentence that all of the socket in this server or all of the
server if it's in a clustered environment have to follow.
|
Server |
all(Action<Socket> action)
Executes the given action retrieving all of the socket in this server or
all of the server if it's in a clustered environment .
|
Sentence |
byId(String id)
Returns a sentence that the socket of the given id in this server or all
of the server if it's in a clustered environment have to follow.
|
Server |
byId(String id,
Action<Socket> action)
Executes the given action retrieving the socket of the given id in this
server or all of the server if it's in a clustered environment.
|
Sentence |
byTag(String... names)
Returns a sentence that the socket tagged with all of the given names in
this server or all of the server if it's in a clustered environment have
to follow.
|
Server |
byTag(String[] names,
Action<Socket> action)
Executes the given action retrieving the socket tagged with all of the
given names in this server or all of the server if it's in a clustered
environment.
|
Server |
byTag(String name,
Action<Socket> action)
Executes the given action retrieving the socket tagged with the given
name in this server or all of the server if it's in a clustered
environment.
|
Action<ServerHttpExchange> |
httpAction()
ServerHttpExchange action to install in wes
|
protected Map<String,Object> |
parseEvent(String text)
Takes a stringified event and returns an event object.
|
protected Map<String,String> |
parseURI(String uri)
Takes a portal URI and returns a map of parameters.
|
Server |
socketAction(Action<Socket> action)
Registers an action to be called when the socket has been opened in this
server regardless of clustering.
|
protected String |
stringifyEvent(Map<String,Object> event)
Takes an event object and returns a stringified event.
|
Action<ServerWebSocket> |
websocketAction()
ServerWebSocket action to install in wes
|
public DefaultServer()
protected Map<String,String> parseURI(String uri)
This is a counterpart of urlBuilder of client option.
protected Map<String,Object> parseEvent(String text)
A text in argument is generated by outbound of client option and
this is akin to inbound of client option.
protected String stringifyEvent(Map<String,Object> event)
This is akin to outbound of client option and a returned value will
be handled by inbound of client option.
public Sentence all()
Serverpublic Server all(Action<Socket> action)
Serverpublic Sentence byId(String id)
Serverpublic Server byId(String id, Action<Socket> action)
Serverpublic Sentence byTag(String... names)
Serverpublic Server byTag(String name, Action<Socket> action)
Serverpublic Server byTag(String[] names, Action<Socket> action)
Serverpublic Server socketAction(Action<Socket> action)
ServersocketAction in interface Serverpublic Action<ServerHttpExchange> httpAction()
ServerhttpAction in interface Serverpublic Action<ServerWebSocket> websocketAction()
ServerwebsocketAction in interface ServerCopyright 2012-2014, Donghwan Kim