Skip to content

Commit 5176283

Browse files
authored
Merge pull request #578 from share/ping-pong-docs
📝 Add `connection.ping()` to the documentation
2 parents 1231351 + e3704a7 commit 5176283

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/api/connection.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,18 @@ The document **must** be of a [type]({{ site.baseurl }}{% link types/index.md %}
229229
Return value
230230

231231
> A [`Presence`]({{ site.baseurl }}{% link api/presence.md %}) instance tied to the given document
232+
233+
### ping()
234+
235+
Send a short message to the server, which will respond with another short message, emitted on the connection as a
236+
`'pong'` event.
237+
238+
```js
239+
connection.ping()
240+
connection.on('pong', () => {
241+
// The server is still there
242+
})
243+
```
244+
245+
{: .warn }
246+
Calling `ping()` when not connected will throw an error with code `ERR_CANNOT_PING_OFFLINE`.

0 commit comments

Comments
 (0)