Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2012-5-15 3:10

Class HookupClient

The Hookup client provides a client for the hookup server, it doesn't lock you in to using a specific message format. The default implementation uses websockets to communicate with the server. You can opt-in or opt-out of every feature in the hookup client through configuration. Usage of the simple hookup client: {{ var myHookup = new Hookup({uri: "ws://localhost:8080/thesocket"}); myHookup.on("open", function() { console.log("The websocket to"+myHookup.uri+" is connected.")'' }); myHookup.on("close", function() { console.log("The websocket to"+myHookup.uri+" disconnected.")'' }); myHookup.on("data", function(data) { if (data.type == "text") { console.log("RECV: "+data.content); myHookup.send("ECHO: "+data.content); } }); }}

Class Summary
Constructor Attributes Constructor Name and Description
 
HookupClient(options)
Creates a new hookup client
Field Summary
Field Attributes Field Name and Description
<static> <constant>  
HookupClient.BUFFER_PATH
The default path for the file buffer to write to.
<static> <constant>  
HookupClient.RECONNECT_SCHEDULE
The default reconnection schedule This is an object with 2 properties, min and max.
 
The schedule (an object with a min and max property) to use for backing-off when reconnecting.
 
uri
The uri this client connects to.

Method Summary

Method Attributes Method Name and Description
 
Disconnect from the socket, perform closing handshake if necessary
 
Connect to the server
 
A flag indicating if this client should fallback to buffering upon disconnection.
 
A flag indicating connection status of the client.
 
send(message)
Send a message over the current connection, buffer the message if not connected and the client is configured to buffer messages.
 
sendAcked(message)
Send a message over the current connection and request that this message will be acked upon receipt by the server.
Event Summary
Event Attributes Event Name and Description
 
on(name, [args])
possible values: open, reconnecting, ack_failed, data, error, disconnect.

Class Detail

HookupClient(options)
Creates a new hookup client
Parameters:
{String|Object} options
{String} options.uri
The uri to connect to.
{Object} options.reconnectSchedule Optional, Default: { min: 1, min: 300 }
The schedule (an object with a min and max property) to use for backing-off.
{WireFormat} options.wireFormat Optional, Default: new WireFormat
The wire format to use with this client.
{FileBuffer} options.buffer Optional, Default: undefined
The buffer to use if you want this client to fallback to buffering.

Field Detail

<static> <constant> {String} HookupClient.BUFFER_PATH
The default path for the file buffer to write to.
<static> <constant> {Number[]} HookupClient.RECONNECT_SCHEDULE
The default reconnection schedule This is an object with 2 properties, min and max. The values entered are seconds
{Object} reconnectSchedule
The schedule (an object with a min and max property) to use for backing-off when reconnecting.
{String} uri
The uri this client connects to.

Method Detail

  • close()
    Disconnect from the socket, perform closing handshake if necessary
  • connect()
    Connect to the server
  • isBuffered()
    A flag indicating if this client should fallback to buffering upon disconnection.
  • isConnected()
    A flag indicating connection status of the client.
    Returns:
    true when the client is connected.
  • send(message)
    Send a message over the current connection, buffer the message if not connected and the client is configured to buffer messages.
    Parameters:
    {String|Object} message
    The message to send
  • sendAcked(message)
    Send a message over the current connection and request that this message will be acked upon receipt by the server. Buffers the message if not connected and the client is configured to buffer messages.
    Parameters:
    {String|Object} message
    The message to send
    {Object} options.timeout Optional, Default: 5000
    The timeout for the ack in milliseconds

Event Detail

on(name, [args])
possible values: open, reconnecting, ack_failed, data, error, disconnect.
Parameters:
{String} name
The name of the event, possible values: open, reconnecting, ack_failed, data, error, disconnect.
{Object} args Optional
The event args