com.glines.socketio.client.jre
Class SocketIOConnectionXHRBase

java.lang.Object
  extended by com.glines.socketio.client.jre.SocketIOConnectionXHRBase
All Implemented Interfaces:
SocketIOConnection

public class SocketIOConnectionXHRBase
extends Object
implements SocketIOConnection


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.glines.socketio.client.common.SocketIOConnection
SocketIOConnection.Factory, SocketIOConnection.SocketIOConnectionListener
 
Field Summary
protected  String closeId
           
protected  org.eclipse.jetty.client.HttpExchange currentGet
           
protected  org.eclipse.jetty.client.HttpExchange currentPost
           
protected  boolean disconnectWhenEmpty
           
protected  AtomicBoolean doingSend
           
protected  ScheduledExecutorService executor
           
protected  boolean isConnectionPersistent
           
protected  AtomicLong messageId
           
protected  BlockingQueue<SocketIOFrame> queue
           
protected  String sessionId
           
protected  ConnectionState state
           
protected  boolean timedout
           
protected  long timeout
           
protected  Future<?> timeoutTask
           
 
Constructor Summary
SocketIOConnectionXHRBase(SocketIOConnection.SocketIOConnectionListener listener, String host, short port, String transport, boolean isConnectionPersistent)
           
 
Method Summary
protected  void _disconnect(DisconnectReason reason, String error)
           
protected  void checkSend()
           
protected  void clearTimeoutTimer()
           
 void close()
          Initiate an orderly close of the connection.
 void connect()
          Initiate a connection attempt.
 void disconnect()
          Forcefully disconnect the connection, discarding any unsent messages.
protected  void doGet()
           
protected  void doSend(String data)
           
protected  org.eclipse.jetty.io.Buffer formatPostData(String data)
           
 ConnectionState getConnectionState()
          Return the current socket connection state.
protected  String getPostContentType()
           
protected  String getPostURI()
           
protected  String getRequestURI()
           
protected  void onClose(String data)
           
protected  void onData(String data)
           
protected  void onFrame(SocketIOFrame frame)
           
protected  void onMessageBlock(String data)
           
protected  void onMessageData(int messageType, String data)
           
protected  void onPing(String data)
           
protected  void onPong(String data)
           
protected  void onTimeout(String error)
           
protected  void sendFrame(SocketIOFrame frame)
           
 void sendMessage(int messageType, String message)
          Send a message.
 void sendMessage(String message)
          Send a message.
protected  void startTimeoutTimer()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionId

protected String sessionId

timeout

protected long timeout

timedout

protected boolean timedout

executor

protected ScheduledExecutorService executor

timeoutTask

protected Future<?> timeoutTask

state

protected ConnectionState state

currentGet

protected org.eclipse.jetty.client.HttpExchange currentGet

currentPost

protected org.eclipse.jetty.client.HttpExchange currentPost

isConnectionPersistent

protected final boolean isConnectionPersistent

queue

protected BlockingQueue<SocketIOFrame> queue

doingSend

protected AtomicBoolean doingSend

messageId

protected AtomicLong messageId

closeId

protected String closeId

disconnectWhenEmpty

protected boolean disconnectWhenEmpty
Constructor Detail

SocketIOConnectionXHRBase

public SocketIOConnectionXHRBase(SocketIOConnection.SocketIOConnectionListener listener,
                                 String host,
                                 short port,
                                 String transport,
                                 boolean isConnectionPersistent)
Method Detail

startTimeoutTimer

protected void startTimeoutTimer()

clearTimeoutTimer

protected void clearTimeoutTimer()

connect

public void connect()
Description copied from interface: SocketIOConnection
Initiate a connection attempt. If the connection succeeds, then the onConnect will be called. If the connection attempt fails, then onDisonnect will be called.

Specified by:
connect in interface SocketIOConnection

close

public void close()
Description copied from interface: SocketIOConnection
Initiate an orderly close of the connection.

Specified by:
close in interface SocketIOConnection

disconnect

public void disconnect()
Description copied from interface: SocketIOConnection
Forcefully disconnect the connection, discarding any unsent messages. This does nothing if the connection is already CLOSED. This will abort an orderly close if one was initiated.

Specified by:
disconnect in interface SocketIOConnection

_disconnect

protected void _disconnect(DisconnectReason reason,
                           String error)

getConnectionState

public ConnectionState getConnectionState()
Description copied from interface: SocketIOConnection
Return the current socket connection state.

Specified by:
getConnectionState in interface SocketIOConnection
Returns:

sendMessage

public void sendMessage(String message)
                 throws SocketIOException
Description copied from interface: SocketIOConnection
Send a message.

Specified by:
sendMessage in interface SocketIOConnection
Throws:
SocketIOException

sendMessage

public void sendMessage(int messageType,
                        String message)
                 throws SocketIOException
Description copied from interface: SocketIOConnection
Send a message. With a default priority of 0.

Specified by:
sendMessage in interface SocketIOConnection
Throws:
SocketIOException

sendFrame

protected void sendFrame(SocketIOFrame frame)

checkSend

protected void checkSend()

onTimeout

protected void onTimeout(String error)

onData

protected void onData(String data)

onMessageBlock

protected void onMessageBlock(String data)

onFrame

protected void onFrame(SocketIOFrame frame)

onClose

protected void onClose(String data)

onPing

protected void onPing(String data)

onPong

protected void onPong(String data)

onMessageData

protected void onMessageData(int messageType,
                             String data)

getRequestURI

protected String getRequestURI()

getPostURI

protected String getPostURI()

doGet

protected void doGet()

getPostContentType

protected String getPostContentType()

formatPostData

protected org.eclipse.jetty.io.Buffer formatPostData(String data)

doSend

protected void doSend(String data)


Copyright © 2010-2011. All Rights Reserved.