diff --git a/docs/API.md b/docs/API.md index 5bad8c860e..99c141d04c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,6 +45,10 @@ - [socket.in(room)](#socketinroom) - [socket.compress(value)](#socketcompressvalue) - [socket.disconnect(close)](#socketdisconnectclose) + - [socket.once(eventName, listener)](#socketonceeventname-listener) + - [socket.removeListener(eventName, listener)](#socketremovelistenereventname-listener) + - [socket.removeAllListeners(\[eventName\])](#socketremovealllistenerseventname) + - [socket.eventNames()](#socketeventnames) - [Flag: 'broadcast'](#flag-broadcast) - [Flag: 'volatile'](#flag-volatile-1) - [Event: 'disconnect'](#event-disconnect) @@ -343,6 +347,8 @@ It should be noted the `Socket` doesn't relate directly to the actual underlying Within each `Namespace`, you can also define arbitrary channels (called `room`) that the `Socket` can join and leave. That provides a convenient way to broadcast to a group of `Socket`s (see `Socket#to` below). +The `Socket` class inherits from [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter). The `Socket` class overrides the `emit` method, and does not modify any other `EventEmitter` method. All methods documented here which also appear as `EventEmitter` methods (apart from `emit`) are implemented by `EventEmitter`, and documentation for `EventEmitter` applies. + #### socket.id * _(String)_ @@ -401,6 +407,7 @@ Sends a `message` event. See [socket.emit(eventName[, ...args][, ack])](#sockete #### socket.emit(eventName[, ...args][, ack]) + - Overrides `EventEmitter.emit` - `eventName` _(String)_ - `args` - `ack` _(Function)_ @@ -434,6 +441,7 @@ io.on('connection', function(client){ #### socket.on(eventName, callback) + - Inherited from `EventEmitter` - `eventName` _(String)_ - `callback` _(Function)_ - **Returns** `Socket` @@ -523,6 +531,13 @@ Sets a modifier for a subsequent event emission that the event data will only be Disconnects this client. If value of close is `true`, closes the underlying connection. Otherwise, it just disconnects the namespace. +#### socket.once(eventName, listener) +#### socket.removeListener(eventName, listener) +#### socket.removeAllListeners([eventName]) +#### socket.eventNames() + +Inherited from `EventEmitter` (along with other methods not mentioned here). See Node.js documentation for the `events` module. + #### Flag: 'broadcast' Sets a modifier for a subsequent event emission that the event data will only be _broadcast_ to every sockets but the sender.