수색…


내부 및 맞춤 이벤트 수신 :

Server Syntax

var io = require('socket.io')(80);

io.on('connection', function (mysocket) {

  //custom event called `private message`
  mysocket.on('private message', function (from, msg) {
    console.log('I received a private message by ', from, ' saying ', msg);
  });

  //internal `disconnect` event fired, when a socket disconnects
  mysocket.on('disconnect', function () {
    console.log('user disconnected');
  });
});

Client syntax :

var mysocket = io('http://example.com');
  mysocket.on('private message', function (data) {
    console.log(data);
});


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow