Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var http = require('http');
  2. var io = require('socket.io');
  3. var loggly = require('loggly');
  4. var path = require('path');  
  5. var paperboy = require('paperboy');
  6.  
  7. var config = {
  8.   subdomain: "geekceo",
  9.   auth: {
  10.     username: "kordless",
  11.     password: "sexytime"
  12.   }
  13. };
  14. var geekceo = loggly.createClient(config);                                                            
  15.  
  16. terms = [];
  17.  
  18. geekceo.facet('date', '404')
  19.   .context({ buckets: 10 })
  20.   .run(function (err, results) {
  21.   });
  22.  
  23. // Start the server at port 8080                                                                      
  24. var server = http.createServer(function(req, res){                                                    
  25.   paperboy.deliver(path.join(path.dirname(__filename), 'static'), req, res);                          
  26. });
  27. server.listen(80);
  28.  
  29. // Create a Socket.IO instance, passing it our server
  30. var socket = io.listen(server);                                                                        
  31.  
  32. // Add a connect listener
  33. socket.on('connection', function(client){
  34.  
  35.   var ping = function() {
  36.     client.send(Math.random());
  37.     console.log("sending");
  38.   }
  39.   interval = setInterval(ping, 1000);
  40.  
  41.   // Success!  Now listen to messages to be received
  42.   client.on('message',function(event){
  43.     console.log('Received message from client!',event);
  44.   });
  45.   client.on('disconnect',function(){
  46.     clearInterval(interval);
  47.     console.log('Server has disconnected');
  48.   });
  49.  
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement