Class R.Socket
A web socket for two-way network communication. You should not
create an object from this class directly. Instead, see
R.util.SocketUtil#createSocket
Defined in: socket.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.Socket()
|
Field Attributes | Field Name and Description |
---|---|
<static> |
R.Socket.MSG_ACK
Socket acknowledges message received and handled type
|
<static> |
R.Socket.MSG_CONNECT
Socket connected message type
|
<static> |
R.Socket.MSG_DISCONNECT
Socket disconnected message type
|
<static> |
R.Socket.MSG_SERVER
Server broadcast message type
|
Method Attributes | Method Name and Description |
---|---|
assure(msg, cb)
Sends a message with a guarantee that will be returned by
the server when the message is received.
|
|
broadcast(msg)
Send a broadcast message to the server.
|
|
connect()
Attempt to connect the socket to its destination.
|
|
done()
Call this method to complete all communications with the socket
and return it to the pool.
|
|
send(msg)
Send a message without a guarantee that the message was
received or handled by the server.
|
Field Detail
<static>
R.Socket.MSG_ACK
Socket acknowledges message received and handled type
<static>
R.Socket.MSG_CONNECT
Socket connected message type
<static>
R.Socket.MSG_DISCONNECT
Socket disconnected message type
<static>
R.Socket.MSG_SERVER
Server broadcast message type
Method Detail
{Number}
assure(msg, cb)
Sends a message with a guarantee that will be returned by
the server when the message is received.
- Parameters:
- msg
- {Object} The message to send
- cb Optional
- {Function} The callback function, or null.
- Returns:
- {Number} The packet number
broadcast(msg)
Send a broadcast message to the server. Broadcast messages
are sent to all connected clients and are not guaranteed.
- Parameters:
- msg
- {Object} The message to send
connect()
Attempt to connect the socket to its destination. Upon
successful connection, the listener() method
attached to the socket will be triggered.
done()
Call this method to complete all communications with the socket
and return it to the pool.
send(msg)
Send a message without a guarantee that the message was
received or handled by the server.
- Parameters:
- msg
- {Object} The message to send