Method
write
(typ MessageType, p []byte)
Source from the content-addressed store, hash-verified
| 211 | } |
| 212 | |
| 213 | func (c *Conn) write(typ MessageType, p []byte) error { |
| 214 | if c.isClosed() { |
| 215 | return net.ErrClosed |
| 216 | } |
| 217 | switch typ { |
| 218 | case MessageBinary: |
| 219 | return c.ws.SendBytes(p) |
| 220 | case MessageText: |
| 221 | return c.ws.SendText(string(p)) |
| 222 | default: |
| 223 | return fmt.Errorf("unexpected message type: %v", typ) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Close closes the WebSocket with the given code and reason. |
| 228 | // It will wait until the peer responds with a close frame |
Tested by
no test coverage detected