You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
46 lines
1.0 KiB
/**
|
|
* @module flitter-socket/ClientServerTransaction
|
|
*/
|
|
|
|
const Transaction = require('./Transaction')
|
|
|
|
/**
|
|
* Specific type of transaction where a request from the
|
|
* client comes in to the server.
|
|
* @extends module:flitter-socket/Transaction~Transaction
|
|
*/
|
|
class ClientServerTransaction extends Transaction {
|
|
|
|
/**
|
|
* Initialize the transaction from the message data.
|
|
* @param data
|
|
* @param cm
|
|
*/
|
|
constructor(data, cm){
|
|
data.incoming = data.data
|
|
super(data, cm)
|
|
|
|
/**
|
|
* The socket handler's requested endpoing.
|
|
* @type {string}
|
|
*/
|
|
this.endpoint = data.endpoint
|
|
}
|
|
|
|
/**
|
|
* Set values in the outgoing data.
|
|
* @param key
|
|
* @param value
|
|
* @returns {ClientServerTransaction} - for chaining
|
|
*/
|
|
set(key, value = null){
|
|
if ( value && typeof this.outgoing === 'object' ) this.outgoing[key] = value
|
|
else this.outgoing = key
|
|
|
|
return this
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = exports = ClientServerTransaction
|