Skip to content

Explicitly document that Server extends EventEmitter #2874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)_
Expand Down Expand Up @@ -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)_
Expand Down Expand Up @@ -434,6 +441,7 @@ io.on('connection', function(client){

#### socket.on(eventName, callback)

- Inherited from `EventEmitter`
- `eventName` _(String)_
- `callback` _(Function)_
- **Returns** `Socket`
Expand Down Expand Up @@ -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.
Expand Down