Socket.io sync looks to be working now...YAY!
This commit is contained in:
		
							parent
							
								
									5ade0c8f9c
								
							
						
					
					
						commit
						e4eb8cb1ec
					
				@ -3,7 +3,6 @@
 | 
			
		||||
  "version": "0.0.1",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "body-parser": "^1.12.4",
 | 
			
		||||
    "chokidar": "^1.6.1",
 | 
			
		||||
    "connect-ensure-login": "^0.1.1",
 | 
			
		||||
    "cookie-parser": "^1.4.3",
 | 
			
		||||
    "express": "^4.12.4",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								server.js
									
									
									
									
									
								
							@ -118,14 +118,10 @@ io.on('connection', function(socket){
 | 
			
		||||
                        winston.info('new contents from client written to allNotes.txt');
 | 
			
		||||
                    });
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        // Send new content to all other clients EXCEPT the orig sender.
 | 
			
		||||
        fileSystem.readFile(notePath, {encoding: 'utf-8'}, function(err,data){
 | 
			
		||||
            if (!err){
 | 
			
		||||
                socket.broadcast.emit('download allNotes',data);
 | 
			
		||||
                // Send new content to all other clients EXCEPT the orig sender.
 | 
			
		||||
                socket.broadcast.emit('download allNotes',msg);
 | 
			
		||||
                winston.info('sent content update to other clients');
 | 
			
		||||
            } else { winston.error(err); }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
    socket.on('cm-save', function(msg){
 | 
			
		||||
@ -133,21 +129,6 @@ io.on('connection', function(socket){
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
//var chokidar = require('chokidar');
 | 
			
		||||
//var watcher = chokidar.watch(notePath, {
 | 
			
		||||
    //ignored: /[\/\\]\./,
 | 
			
		||||
    //persistent: true
 | 
			
		||||
//});
 | 
			
		||||
//watcher.on('change', function(){
 | 
			
		||||
    //winston.info('file watcher change event');
 | 
			
		||||
    //fileSystem.readFile(notePath, {encoding: 'utf-8'}, function(err,data){
 | 
			
		||||
        //if (!err){
 | 
			
		||||
            //winston.info('successful file read');
 | 
			
		||||
            //io.emit('download allNotes',data);
 | 
			
		||||
        //} else { winston.error(err); }
 | 
			
		||||
    //});
 | 
			
		||||
//});
 | 
			
		||||
 | 
			
		||||
http.listen(3000, function() {
 | 
			
		||||
    winston.info("Started on PORT 3000");
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user