public class DefaultSocket extends java.lang.Object implements Socket
SocketSocket.STATUS| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<FunctionWrapper> |
functions |
protected Options |
options |
protected Request |
request |
protected SocketRuntime |
socketRuntime |
protected Transport |
transportInUse |
| Constructor and Description |
|---|
DefaultSocket(Options options) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addFunction(long timeout,
java.util.concurrent.TimeUnit tu) |
void |
close()
Close this Socket, asynchronously.
|
protected void |
closeRuntime(boolean async) |
protected Socket |
connect(com.ning.http.client.RequestBuilder r,
java.util.List<Transport> transports,
long timeout,
java.util.concurrent.TimeUnit tu) |
SocketRuntime |
createRuntime(DefaultFuture future,
Options options,
java.util.List<FunctionWrapper> functions) |
Future |
fire(java.lang.Object data)
Send data to the remote Server.
|
protected java.util.List<Transport> |
getTransport(com.ning.http.client.RequestBuilder r,
Request request) |
protected SocketRuntime |
internalSocket() |
Socket |
on(Event event,
Function<?> function)
|
Socket |
on(Function<? extends java.lang.Object> function)
Associate a
Function with the Socket. |
Socket |
on(java.lang.String functionName,
Function<? extends java.lang.Object> function)
Associate a
Function with the Socket. |
Socket |
open(Request request)
Connect to the remote Server using the
Request's information. |
Socket |
open(Request request,
long timeout,
java.util.concurrent.TimeUnit tu)
Connect to the remote Server using the
Request's information, will timeout if the connection failed to open
within a certain time. |
protected Request |
request() |
Socket.STATUS |
status()
Return the
Socket.STATUS of this Socket. |
protected Request request
protected SocketRuntime socketRuntime
protected final java.util.List<FunctionWrapper> functions
protected Transport transportInUse
protected final Options options
public DefaultSocket(Options options)
public Future fire(java.lang.Object data) throws java.io.IOException
Encoder, and then send to the server.
The server's response will be delivered to the set of defined Function using the opened Transport, e.g for
Request.TRANSPORT.WEBSOCKET, the same connection will be re-used and, for others transports, the suspended connection.public Socket on(java.lang.String functionName, Function<? extends java.lang.Object> function)
Function with the Socket. When a response is received, the library will try to associated
the decoded message (decoded by Decoder) to the defined type of the Function. The default messages
are defined by Event but handling of custom message can be done using a FunctionResolverpublic Socket open(Request request) throws java.io.IOException
SocketRequest's information.public Socket open(Request request, long timeout, java.util.concurrent.TimeUnit tu) throws java.io.IOException
Request's information, will timeout if the connection failed to open
within a certain time.protected Socket connect(com.ning.http.client.RequestBuilder r, java.util.List<Transport> transports, long timeout, java.util.concurrent.TimeUnit tu) throws java.io.IOException
java.io.IOExceptionprotected void addFunction(long timeout,
java.util.concurrent.TimeUnit tu)
public void close()
protected void closeRuntime(boolean async)
public Socket.STATUS status()
SocketSocket.STATUS of this Socket.protected SocketRuntime internalSocket()
protected java.util.List<Transport> getTransport(com.ning.http.client.RequestBuilder r, Request request) throws java.io.IOException
java.io.IOExceptionprotected Request request()
public SocketRuntime createRuntime(DefaultFuture future, Options options, java.util.List<FunctionWrapper> functions)
Copyright © 2019. All Rights Reserved.