public class SockJsConnection extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
SockJsConnection.OnCloseHandler |
static interface |
SockJsConnection.OnDataHandler |
Modifier and Type | Field and Description |
---|---|
Map<String,String> |
headers
Hash containing various headers copied from last request received on
this connection.
|
String |
id
Unique identifier of this connection
|
String |
pathname
`pathname` from parsed url, for convenience.
|
String |
prefix
Prefix of the url on which the request was handled.
|
String |
protocol
Protocol used by the connection.
|
String |
remoteAddress
Last known IP address of the client.
|
int |
remotePort
Last known port number of the client.
|
String |
url
The entire url string copied from the last request.
|
Constructor and Description |
---|
SockJsConnection(Session session) |
Modifier and Type | Method and Description |
---|---|
boolean |
close()
Ask the remote client to disconnect with default 'code' and 'reason'
values
|
boolean |
close(int code,
String reason)
Asks the remote client to disconnect with the given 'code' and 'reason' values
|
void |
destroy() |
void |
emitClose() |
void |
emitData(String message) |
void |
end()
Asks the remote client to disconnect with default 'code' and 'reason' values.
|
void |
end(String message)
Write a message and then ask the remote client to disconnect with
default 'code' and 'reason' values.
|
Transport.READY_STATE |
getReadyState()
Current state of the connection
|
void |
onClose(SockJsConnection.OnCloseHandler onCloseHandler)
Called when a connection to a client is closed.
|
void |
onData(SockJsConnection.OnDataHandler onDataHandler)
Called for every message received from a client
|
String |
toString() |
boolean |
write(String message,
boolean async)
Sends a message over the opened connection.
|
public String id
public String remoteAddress
public int remotePort
public Map<String,String> headers
public String url
public String pathname
public String prefix
public String protocol
public SockJsConnection(Session session)
public boolean write(String message, boolean async)
message
- the message to sendpublic void end()
public void end(String message)
message
- message to writepublic boolean close()
public boolean close(int code, String reason)
code
- The code, typically one of CloseReason.CloseCodes.getCode()
reason
- A string describing the reason for closurepublic void destroy()
public void onData(SockJsConnection.OnDataHandler onDataHandler)
onDataHandler
- The handler to call when messages arrivepublic void emitData(String message)
public void onClose(SockJsConnection.OnCloseHandler onCloseHandler)
onCloseHandler
- The handler to call when a connection is closedpublic void emitClose()
public Transport.READY_STATE getReadyState()
Copyright © 2015. All rights reserved.