Skip to content

Commit add3c11

Browse files
committed
add javascript example of how to supply password as i think my
explanation is confusing
1 parent 38c0de5 commit add3c11

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/sending-commands/websocket.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ With `WEBSOCKET_CONSOLE` set to `true`, logs can be streamed, and commands sent,
66

77
## Password
88
A password must be supplied using the `Sec-WebSocket-Protocol` header. This is done by putting `mc-server-runner-ws-v1` in the first slot, and the password in the second. The password can be set with `RCON_PASSWORD` or `WEBSOCKET_PASSWORD`. The latter overwrites the former. Authentication can be disabled with `WEBSOCKET_DISABLE_AUTHENTICATION`.
9+
??? Example "Examples"
10+
```js title="JavaScript example"
11+
let socket = new WebSocket("http://localhost:80/websocket", ["mc-server-runner-ws-v1", "rcon-password"]);
12+
```
913

1014
## Allowed origins
1115
A list of comma-separated allowed origins should be supplied with `WEBSOCKET_ALLOWED_ORIGINS`. Origin checking can be disabled with `WEBSOCKET_DISABLE_ORIGIN_CHECK`.

0 commit comments

Comments
 (0)