io.socket
Class XhrTransport

java.lang.Object
  extended by io.socket.XhrTransport
All Implemented Interfaces:
IOTransport

 class XhrTransport
extends java.lang.Object
implements IOTransport

The Class XhrTransport.


Field Summary
(package private)  io.socket.XhrTransport.PollThread pollThread
          background thread for managing the server connection.
(package private)  java.util.concurrent.ConcurrentLinkedQueue<java.lang.String> queue
          The queue holding elements to send.
static java.lang.String TRANSPORT_NAME
          The String to identify this Transport.
(package private)  java.net.HttpURLConnection urlConnection
           
 
Constructor Summary
XhrTransport(java.net.URL url, IOConnection connection)
          Instantiates a new xhr transport.
 
Method Summary
 boolean canSendBulk()
          return true if the IOTransport prefers to send multiple messages at a time.
 void connect()
          Instructs the IOTransport to connect.
static IOTransport create(java.net.URL url, IOConnection connection)
          Creates a new Transport for the given url an IOConnection.
 void disconnect()
          Instructs the IOTransport to disconnect.
 java.lang.String getName()
           
 void invalidate()
          Instructs the IOTransport to invalidate.
 void send(java.lang.String text)
          Instructs the IOTransport to send a Message
 void sendBulk(java.lang.String[] texts)
          Instructs the IOTransport to send multiple messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSPORT_NAME

public static final java.lang.String TRANSPORT_NAME
The String to identify this Transport.

See Also:
Constant Field Values

queue

java.util.concurrent.ConcurrentLinkedQueue<java.lang.String> queue
The queue holding elements to send.


pollThread

io.socket.XhrTransport.PollThread pollThread
background thread for managing the server connection.


urlConnection

java.net.HttpURLConnection urlConnection
Constructor Detail

XhrTransport

public XhrTransport(java.net.URL url,
                    IOConnection connection)
Instantiates a new xhr transport.

Parameters:
url - the url
connection - the connection
Method Detail

create

public static IOTransport create(java.net.URL url,
                                 IOConnection connection)
Creates a new Transport for the given url an IOConnection.

Parameters:
url - the url
connection - the connection
Returns:
the iO transport

connect

public void connect()
Description copied from interface: IOTransport
Instructs the IOTransport to connect.

Specified by:
connect in interface IOTransport

disconnect

public void disconnect()
Description copied from interface: IOTransport
Instructs the IOTransport to disconnect.

Specified by:
disconnect in interface IOTransport

send

public void send(java.lang.String text)
          throws java.io.IOException
Description copied from interface: IOTransport
Instructs the IOTransport to send a Message

Specified by:
send in interface IOTransport
Parameters:
text - the text to be sent
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

canSendBulk

public boolean canSendBulk()
Description copied from interface: IOTransport
return true if the IOTransport prefers to send multiple messages at a time.

Specified by:
canSendBulk in interface IOTransport
Returns:
true, if successful

sendBulk

public void sendBulk(java.lang.String[] texts)
              throws java.io.IOException
Description copied from interface: IOTransport
Instructs the IOTransport to send multiple messages. This is only called when canSendBulk returns true.

Specified by:
sendBulk in interface IOTransport
Parameters:
texts - the texts
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

invalidate

public void invalidate()
Description copied from interface: IOTransport
Instructs the IOTransport to invalidate. DO NOT DISCONNECT from the server. just make sure, that events are not populated to the IOConnection

Specified by:
invalidate in interface IOTransport

getName

public java.lang.String getName()
Specified by:
getName in interface IOTransport