最終更新:2017-07-20 (木) 02:01:22 (2443d)
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);
イベント
サーバ
- Exposed by require('socket.io').
- https://socket.io/docs/server-api/
Server
メソッド
- コンストラクタ
- new Server(http.Server,options)
- new Server(port[, options])
- new Server(options)
インスタンス化
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
- https://socket.io/docs/client-api/#io
- Exposed as the io namespace in the standalone build
<script src="/socket.io/socket.io.js"></script> var socket = io.connect();
コンストラクタ
- 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
メソッド
- io.connect();