最終更新:2017-07-20 (木) 02:01:22 (2464d)  

socket.io
Top / socket.io

メモ

  • var app = require('http').createServer(handler)
    var io = require('socket.io')(app);
  • var socketio = require('socket.io');
    var server = http.createServer(....).listen(3000);
    var io = socketio.listen(server);

イベント

サーバ

Server

メソッド

インスタンス化

  • const io = require('socket.io')();
  • or
    const Server = require('socket.io');
    const io = new Server();

リッスン

  • server.listen(httpServer[, options]) - Synonym of server.attach(httpServer[, options]).
  • server.listen(port[, options]) - Synonym of server.attach(port[, options]).

アタッチ

  • server.attach(httpServer[, options]) - Attaches the Server to an engine.io instance on httpServer with the supplied options (optionally).
  • server.attach(port[, options]) - Attaches the Server to an engine.io instance on a new http.Server with the supplied options (optionally).

Socket

Client

クライアント

IO

コンストラクタ

  • Creates a new Manager for the given URL
  • io([url][, options])
    • url (String) (defaults to window.location)
    • options (Object)
  • returns Socket

メソッド

  • var socket = io('http://localhost');
    var socket = io.connect();

Manager

Socket

メソッド