-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBaseConnection.js
44 lines (32 loc) · 1.1 KB
/
BaseConnection.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const net = require('net'),
util = require('util'),
events = require('events'),
uuid = require('uuid');
const i2putil = require("./i2putil");
const Sam = require("./Sam");
module.exports = function() {
var self = this;
Sam.call(this);
self.on('cmdStreamStatus', self.handleCmdStreamStatus.bind(self));
self.base_connection_options = i2putil.copyObj(self.base_connection_options);
}
util.inherits(module.exports, Sam);
module.exports.prototype.base_connection_options = {
ID: undefined,
DESTINATION: undefined
}
module.exports.prototype.connect = function (base_connection_options, sam_options) {
var self = this;
i2putil.copyObj(base_connection_options, self.base_connection_options);
Sam.prototype.connect.call(self, sam_options);
}
module.exports.prototype.handleCmdHelloReply = function(data) {
var self = this;
Sam.prototype.handleCmdHelloReply.call(self, data);
self.sendCmd(["STREAM", "CONNECT"], self.base_connection_options);
}
module.exports.prototype.handleCmdStreamStatus = function(data) {
var self = this;
client.reuseConn();
self.emit("connect");
}