最終更新:2017-09-16 (土) 21:02:22 (2385d)
io.Socket
Top / io.Socket
https://socket.io/docs/client-api/#socket
Client
const socket = io('http://localhost'); var socket = io("http://localhost:3000/").connect();
メソッド
String socket.id An unique identifier for the socket session. io.Socket socket.open() Manually opens the socket. io.Socket socket.connect() Synonym of socket.open(). io.Socket socket.send?([...args][, ack]) Sends a message event. io.Socket socket.emit(eventName[, ...args][, ack]) Emits an event to the socket identified by the string name io.Socket socket.on(eventName, callback) Register a new handler for the given event. io.Socket socket.compress?(value) Sets a modifier for a subsequent event emission that the event data will only be compressed if the value is true. io.Socket socket.close?() Disconnects the socket manually. io.Socket socket.disconnect?() Synonym of socket.close?().
イベント
connect Fired upon a connection including a successful reconnection. connect_error Fired upon a connection error. connect_timeout Fired upon a connection timeout. error Fired when an error occurs. diconnect Fired upon a disconnection. reconnect Fired upon a successful reconnection. reconnect_attempt Fired upon an attempt to reconnect. reconnecting Fired upon an attempt to reconnect. reconnect_error Fired upon a reconnection attempt error. reconnect_failed Fired when couldn't reconnect within reconnectionAttempts. ping Fired when a ping packet is written out to the server. pong Fired when a pong is received from the server.