Documentation
¶
Overview ¶
Package websocket provides high-level bindings for the browser's WebSocket API.
These bindings offer a Dial function that returns a regular net.Conn. It can be used similarly to net package.
conn, err := websocket.Dial("ws://localhost/socket") // Blocks until connection is established.
if err != nil {
// handle error
}
buf := make([]byte, 1024)
n, err = conn.Read(buf) // Blocks until a WebSocket frame is received.
doSomethingWithData(buf[:n])
if err != nil {
// handle error
}
_, err = conn.Write([]byte("Hello!"))
// ...
err = conn.Close()
// ...
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Notes ¶
Bugs ¶
conn.LocalAddr() panics because the underlying JavaScript API has no way of figuring out the local address.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package websocketjs provides low-level bindings for the browser's WebSocket API.
|
Package websocketjs provides low-level bindings for the browser's WebSocket API. |
Click to show internal directories.
Click to hide internal directories.