-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (33 loc) · 1.07 KB
/
app.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
var io = require('socket.io-client'),
thingService = require('./thingService');
var port = '80',
server = 'thing.everymote.com';
var connectThing = function(thing, onAction){
console.log(thing);
var socket = io.connect('http://' + server + ':' + port + '/thing'
,{"force new connection":true
,'reconnect': true
,'reconnection delay': 5000
,'reconnection limit': 5000
,'max reconnection attempts': 10 });
socket.on('connect', function () {
console.log('connected');
socket.emit('setup', thing.settings);
}).on('doAction', function (action) {
thing.onAction(action);
}).on('connect_failed', function () {
console.log('error:' + socket );
}).on('disconnect', function () {
console.log('disconnected');
}).on('reconnect', function () {
console.log('reconnect');
}).on('reconnecting', function () {
console.log('reconnecting');
}).on('reconnect_failed', function () {
console.log('reconnect_failed');
});
};
var start = function(action){
connectThing(thingService.thing, action);
};
start();