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 |
---|---|
Server |
all(Action<Socket> action)
Executes the given action retrieving all of the socket in this server.
|
Server |
byId(String id,
Action<Socket> action)
Executes the given action retrieving the socket of the given id.
|
Server |
byTag(String[] names,
Action<Socket> action)
Executes the given action retrieving the socket tagged with all of the
given names.
|
Server |
byTag(String name,
Action<Socket> action)
Executes the given action retrieving the socket tagged with the given
name.
|
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.
|
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 Server all(Action<Socket> action)
Server
public Server byId(String id, Action<Socket> action)
Server
public Server byTag(String name, Action<Socket> action)
Server
public Server byTag(String[] names, Action<Socket> action)
Server
public Server socketAction(Action<Socket> action)
Server
socketAction
in interface Server
public Action<ServerHttpExchange> httpAction()
Server
httpAction
in interface Server
public Action<ServerWebSocket> websocketAction()
Server
websocketAction
in interface Server
Copyright 2012-2014, Donghwan Kim