Skip to content

Commit

Permalink
[docs] Document connected and disconnected socket properties (#1155)
Browse files Browse the repository at this point in the history
  • Loading branch information
perrin4869 authored and darrachequesne committed Feb 28, 2018
1 parent f31837f commit bb743c4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
- [Event: 'pong'](#event-pong)
- [Class: io.Socket](#socket)
- [socket.id](#socketid)
- [socket.connected](#socketconnected)
- [socket.disconnected](#socketdisconnected)
- [socket.open()](#socketopen)
- [socket.connect()](#socketconnect)
- [socket.send([...args][, ack])](#socketsendargs-ack)
Expand Down Expand Up @@ -396,6 +398,34 @@ socket.on('connect', () => {
});
```

#### socket.connected

- _(Boolean)_

Whether or not the socket is connected to the server.

```js
const socket = io('http://localhost');

socket.on('connect', () => {
console.log(socket.connected); // true
});
```

#### socket.disconnected

- _(Boolean)_

Whether or not the socket is disconnected from the server.

```js
const socket = io('http://localhost');

socket.on('connect', () => {
console.log(socket.disconnected); // false
});
```

#### socket.open()

- **Returns** `Socket`
Expand Down

0 comments on commit bb743c4

Please sign in to comment.