File: README.md

package info (click to toggle)
golang-nhooyr-websocket 1.8.12-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 528 kB
  • sloc: asm: 158; sh: 101; javascript: 62; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Echo Example

This directory contains a echo server example using github.com/coder/websocket.

```bash
$ cd examples/echo
$ go run . localhost:0
listening on ws://127.0.0.1:51055
```

You can use a WebSocket client like https://github.com/hashrocket/ws to connect. All messages
written will be echoed back.

## Structure

The server is in `server.go` and is implemented as a `http.HandlerFunc` that accepts the WebSocket
and then reads all messages and writes them exactly as is back to the connection.

`server_test.go` contains a small unit test to verify it works correctly.

`main.go` brings it all together so that you can run it and play around with it.