Basic socket.io event is working.
This commit is contained in:
		
							parent
							
								
									6b7800fb66
								
							
						
					
					
						commit
						15d9f02133
					
				@ -15,6 +15,7 @@
 | 
			
		||||
    "passport-local": "^1.0.0",
 | 
			
		||||
    "pg": "^4.4.3",
 | 
			
		||||
    "serve-favicon": "^2.3.0",
 | 
			
		||||
    "socket.io": "^1.5.1",
 | 
			
		||||
    "sqlite3": "^3.0.8",
 | 
			
		||||
    "winston": "^2.1.1"
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								server.js
									
									
									
									
									
								
							@ -140,6 +140,16 @@ app.get('/logout', function(req, res){
 | 
			
		||||
    res.redirect('/');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
app.listen(3000, function() {
 | 
			
		||||
var http = require('http').Server(app);
 | 
			
		||||
var io = require('socket.io')(http);
 | 
			
		||||
 | 
			
		||||
io.on('connection', function(socket){
 | 
			
		||||
    //winston.info('a user connected');
 | 
			
		||||
    socket.on('cm-save', function(msg){
 | 
			
		||||
        winston.info(msg);
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
http.listen(3000, function() {
 | 
			
		||||
    winston.info("Started on PORT 3000");
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,7 @@
 | 
			
		||||
<script src="mode/markdown/markdown.js"></script>
 | 
			
		||||
<script src="addon/edit/matchbrackets.js"></script>
 | 
			
		||||
<script src="keymap/vim.js"></script>
 | 
			
		||||
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
 | 
			
		||||
<style type="text/css">
 | 
			
		||||
    html, body { height: 100%; margin: 0; padding: 0; }
 | 
			
		||||
    .wrap {
 | 
			
		||||
@ -67,7 +68,11 @@
 | 
			
		||||
    // This no worky, there's no concept of <leader> in CodeMirror, but i was hoping this would work-around it.
 | 
			
		||||
    //CodeMirror.Vim.map(' c', '<Esc>o- [ ] ', 'normal')
 | 
			
		||||
    //CodeMirror.Vim.map(' x', '<ESC>;s/\[\s\]/[x]/g<CR>;noh<CR>', 'normal')
 | 
			
		||||
    //CodeMirror.commands.save = function(){ alert("Saving"); }
 | 
			
		||||
    CodeMirror.commands.save = function(){
 | 
			
		||||
        //alert("Saving");
 | 
			
		||||
        var socket = io();
 | 
			
		||||
        socket.emit('cm-save', 'codemirror save event');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var typingTimer;
 | 
			
		||||
    editor.on("changes", function() {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user