com.pusher.client.connection.websocket
Class WebSocketConnection

java.lang.Object
  extended by com.pusher.client.connection.websocket.WebSocketConnection
All Implemented Interfaces:
Connection, InternalConnection, WebSocketListener

public class WebSocketConnection
extends Object
implements InternalConnection, WebSocketListener


Constructor Summary
WebSocketConnection(String apiKey, boolean encrypted)
           
 
Method Summary
 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(ServerHandshake handshakedata)
           
 void sendMessage(String message)
          InternalConnection implementation detail
 boolean unbind(ConnectionState state, ConnectionEventListener eventListener)
          Unbind from connection state changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebSocketConnection

public WebSocketConnection(String apiKey,
                           boolean encrypted)
                    throws URISyntaxException
Throws:
URISyntaxException
Method Detail

connect

public void connect()
Description copied from interface: Connection
No need to call this via the API. Instead use com.pusher.client.Pusher.connect().

Specified by:
connect in interface Connection

disconnect

public void disconnect()
Specified by:
disconnect in interface InternalConnection

bind

public void bind(ConnectionState state,
                 ConnectionEventListener eventListener)
Description copied from interface: Connection
Bind to connection events.

Specified by:
bind in interface Connection
Parameters:
state - The states to bind to.
eventListener - A listener to be called when the state changes.

unbind

public boolean unbind(ConnectionState state,
                      ConnectionEventListener eventListener)
Description copied from interface: Connection
Unbind from connection state changes.

Specified by:
unbind in interface Connection
Parameters:
state - The state to unbind from.
eventListener - The listener to be unbound.
Returns:
true if the unbind was successful, otherwise false.

getState

public ConnectionState getState()
Description copied from interface: Connection
Gets the current connection state.

Specified by:
getState in interface Connection
Returns:
The state.

sendMessage

public void sendMessage(String message)
InternalConnection implementation detail

Specified by:
sendMessage in interface InternalConnection

getSocketId

public String getSocketId()
Description copied from interface: Connection
Gets a unique connection ID.

Specified by:
getSocketId in interface Connection
Returns:
The id.

onOpen

public void onOpen(ServerHandshake handshakedata)
Specified by:
onOpen in interface WebSocketListener

onMessage

public void onMessage(String message)
Specified by:
onMessage in interface WebSocketListener

onClose

public void onClose(int code,
                    String reason,
                    boolean remote)
Specified by:
onClose in interface WebSocketListener

onError

public void onError(Exception ex)
Specified by:
onError in interface WebSocketListener


Copyright © 2013 Pusher. All Rights Reserved.