-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.js
More file actions
56 lines (42 loc) · 1.46 KB
/
server.js
File metadata and controls
56 lines (42 loc) · 1.46 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
var express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var util = require('util'),
twitter = require('twitter');
var twit = new twitter({
consumer_key: 'loKSPYFml4LivjXsMjHzqXv3c',
consumer_secret: 'cZmUwJbIZoWZU6EFo7kWGkdCrwh1QB30EoVEVUQfFM1BOIfQ2A',
access_token_key: '32316084-PvKj8q58u2S58M17YOCyd2UoGTUPfG9pcfbFFQt8Z',
access_token_secret: 'hYdFyezlJWrAhagBGoXjdOsaoKLXMESr0gu28eagxSs6K'
});
server.listen(8080);
app.use(express.static(__dirname + '/'));
app.get('/', function(req, response){
response.sendFile(__dirname + "/index.html");
});
var message_counter = 0;
io.on('connection', function (client) {
console.log('Connection received.');
client.on('oscdata', function(oscdata){
console.log(Date.now() - oscdata.timeInMs + "ms of latency"); //Outputs latency from the local to the remote server
client.broadcast.emit(oscdata.address, oscdata);
message_counter += 1;
if(message_counter % 2000 == 0) {
console.log('Recieved 2k messages ' + message_counter / 2000);
}
});
client.on('zenachieved', function(data){
// var tweet = "I've achieved zen @TechCrunch #HackDisrupt w/ @cimbriano, @sparkdevices, @digitalocean, and @twitterdev.";
var tweet = "Zentesting.";
twit
.verifyCredentials(function(data) {
// console.log(util.inspect(data));
})
.updateStatus(tweet,
function(data) {
// console.log(util.inspect(data));
}
);
});
});