public class WebSocketConnection extends Object implements InternalConnection, WebSocketListener
Constructor and Description |
---|
WebSocketConnection(String url,
long activityTimeout,
long pongTimeout,
Factory factory) |
Modifier and Type | Method and Description |
---|---|
void |
bind(ConnectionState state,
ConnectionEventListener eventListener)
Bind to connection events.
|
void |
connect()
No need to call this via the API.
|
void |
disconnect() |
String |
getSocketId()
Gets a unique connection ID.
|
ConnectionState |
getState()
Gets the current connection state.
|
void |
onClose(int code,
String reason,
boolean remote) |
void |
onError(Exception ex) |
void |
onMessage(String message) |
void |
onOpen(org.java_websocket.handshake.ServerHandshake handshakedata) |
void |
sendMessage(String message) |
boolean |
unbind(ConnectionState state,
ConnectionEventListener eventListener)
Unbind from connection state changes.
|
public WebSocketConnection(String url, long activityTimeout, long pongTimeout, Factory factory) throws URISyntaxException
URISyntaxException
public void connect()
Connection
Pusher.connect()
.connect
in interface Connection
public void disconnect()
disconnect
in interface InternalConnection
public void bind(ConnectionState state, ConnectionEventListener eventListener)
Connection
bind
in interface Connection
state
- The states to bind to.eventListener
- A listener to be called when the state changes.public boolean unbind(ConnectionState state, ConnectionEventListener eventListener)
Connection
unbind
in interface Connection
state
- The state to unbind from.eventListener
- The listener to be unbound.true
if the unbind was successful, otherwise
false
.public ConnectionState getState()
Connection
getState
in interface Connection
public void sendMessage(String message)
sendMessage
in interface InternalConnection
public String getSocketId()
Connection
getSocketId
in interface Connection
public void onOpen(org.java_websocket.handshake.ServerHandshake handshakedata)
onOpen
in interface WebSocketListener
public void onMessage(String message)
onMessage
in interface WebSocketListener
public void onClose(int code, String reason, boolean remote)
onClose
in interface WebSocketListener
public void onError(Exception ex)
onError
in interface WebSocketListener
Copyright © 2018 Pusher. All rights reserved.