comparison isshouni.js @ 5:4a063df30be9

Correctly exit.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 23 Feb 2012 21:47:21 +0100
parents e6f5077c2ea9
children 377a9b42226a
comparison
equal deleted inserted replaced
4:e6f5077c2ea9 5:4a063df30be9
46 46
47 var disconnect = function() { 47 var disconnect = function() {
48 cl.send(new xmpp.Element('presence', {to: config.muc + '/' + config.nick, type: 'unavailable'})); 48 cl.send(new xmpp.Element('presence', {to: config.muc + '/' + config.nick, type: 'unavailable'}));
49 process.stdin.end(); 49 process.stdin.end();
50 cl.end(); 50 cl.end();
51
52 tty.setRawMode(false);
53 setTimeout(process.exit, 1000);
51 }; 54 };
52 55
53 var send_message = function(name, arg, type) { 56 var send_message = function(name, arg, type) {
54 //console.log('SENT: ' + name + ' ' + arg); 57 //console.log('SENT: ' + name + ' ' + arg);
55 if (!type) 58 if (!type)
124 return; 127 return;
125 } 128 }
126 if (!connected) 129 if (!connected)
127 return; 130 return;
128 131
129 console.log('New participant: ' + from.resource); 132 /*console.log('New participant: ' + from.resource);
130 133
131 if (paused) 134 if (paused)
132 send_message('paused', undefined, 'chat'); 135 send_message('paused', undefined, 'chat');*/
133 }; 136 };
134 137
135 cl.on('error', function(e) { 138 cl.on('error', function(e) {
136 console.log(e); 139 console.log(e);
137 }); 140 });
147 if (paused) 150 if (paused)
148 send_command('get_time_pos'); 151 send_command('get_time_pos');
149 return 'pause'; 152 return 'pause';
150 }, 153 },
151 'q': function() { 154 'q': function() {
152 tty.setRawMode(false);
153 disconnect(); 155 disconnect();
154 process.exit();
155 return 'quit'; 156 return 'quit';
156 }, 157 },
157 }; 158 };
158 159
159 var seek = function(time) { 160 var seek = function(time) {