-
Notifications
You must be signed in to change notification settings - Fork 0
/
emit.js
44 lines (39 loc) · 1.28 KB
/
emit.js
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
//-------------------------------------------------------//
//socket.ioテスト用シェル
//-------------------------------------------------------//
var util = require('util');
var event = 'login';
var data = {
count: 1
};
//-------------------------------------------------------//
//socket.ioへのイベント送信クライアント
var io = require('socket.io-client');
//socket.ioに接続
var host = 'http://localhost';
var port = 20082;
if(isFinite(process.argv[3])){
port = process.argv[3] ;
}
var socket = io.connect(host+':'+port);
//-------------------------------------------------------//
//データ送信
socket.emit(event, data);
var timeout;
//-------------------------------------------------------//
console.log('socket.emit = '+util.inspect(data,false,null));
socket.on('connect', function(){
console.log('socket connect = ');
socket.on('message',function(msg){
console.log('eventOn message msg = '+util.inspect(msg,false,null));
});
socket.on('logined',function(msg){
console.log('eventOn logined msg = '+util.inspect(msg,false,null));
});
socket.on('error',function(msg){
console.log('eventOn error msg = '+util.inspect(msg,false,null));
});
socket.on('disconnect',function(msg){
console.log('eventOn disconnect msg = '+util.inspect(msg,false,null));
});
});