Constructor
new ServerClientTransaction(data, cm)
Initialize the transaction. Set the outgoing data and the endpoint.
| Name | Type | Description | 
|---|---|---|
data | 
            
            Object | information to load into this transaction  | 
        
cm | 
            
            module:flitter-socket/ConnectionManager~ConnectionManager | the associated connection manager  | 
        
- Source:
 
Extends
Members
(private) _message :string
Message to be included in the response. User this.message() to get/set.
- string
 
- Source:
 
(private) _status :number
HTTP-equivalent status code for this transaction. Use this.status() to get/set.
- number
 
- Source:
 
cm :module:flitter-socket/ConnectionManager~ConnectionManager
The connection manager that spawned this transaction.
- Source:
 
connection_id :string
Unique ID of the websocket client's connection in the connection manager.
- string
 
- Source:
 
endpoint :string
The endpoint of this transaction. Typically, corresponds to the name of a method in a controller somewhere.
- string
 
- Source:
 
id :string
Universally-unique id of this transaction. Used by both parties to match up requests and responses.
- string
 
- Source:
 
incoming :Object
Contains the incoming data for the transaction. That is, the data from the sender.
- Object
 
- Source:
 
outgoing :Object
Contains the outgoing data for the transaction. That is, the data sent/to be sent back to the sender.
- Object
 
- Source:
 
received :boolean
Set to true if 1. the transaction was awaiting data and 2. the data has been received
- boolean
 
- Source:
 
resolved :boolean
Whether the transaction has completed. That is, has the recipient sent a response.
- boolean
 
- Source:
 
sent :boolean
Set to true if 1. this transaction is a response and 2. the response has been sent
- boolean
 
- Source:
 
socket :Socket
The open websocket used for communication
- Socket
 
- Source:
 
type :"request"|"response"
Is this a request or a response-type transaction?
- "request" | "response"
 
- Source:
 
Methods
(private) _handler()
Callback function called when the client sends a valid response. Use this.handler() to get/set.
- Source:
 
handler(fnopt) → {ServerClientTransaction|function}
Get or set the callback function. If no function is provided, returns the current callback function. If one is specified, set this._handler and return this for chaining.
| Name | Type | Attributes | Description | 
|---|---|---|---|
fn | 
            
            function | 
                
                    <optional> | 
            
            
            
- Source:
 
- if fn is specified, this; otherwise, the current callback function
 
- Type
 - ServerClientTransaction | function
 
message(msgopt) → {Transaction|string}
Get or set the message. If a new message is provided, set the message and return this for chaining. Otherwise get the current message.
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
msg | 
            
            string | 
                
                    <optional> | 
            
            
                null | 
- Source:
 
- if message is provided, set the message and return this; otherwise return the current message
 
- Type
 - Transaction | string
 
receipt(data)
Called when data is received from the client. Sets this.received to true and calls the callback handler.
| Name | Type | Description | 
|---|---|---|
data | 
            
            object | 
- Source:
 
resolve()
Mark the transaction as resolved.
- Source:
 
send(data) → {*|boolean|void}
Send data to the recipient of this transaction as stringified JSON, and resolve the transaction.
| Name | Type | Description | 
|---|---|---|
data | 
            
            
- Source:
 
- Type
 - * | boolean | void
 
status(codeopt) → {Transaction|number}
Get or set the status code. If a new code is provided, set the status code and return this for chaining. Otherwise, get the current status code.
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
code | 
            
            number | 
                
                    <optional> | 
            
            
                null | 
- Source:
 
- if code is provided, set the code and return this; otherwise return the current code
 
- Type
 - Transaction | number