MCPcopy Index your code
hub / github.com/coder/websocket / write

Method write

ws_js.go:213–225  ·  view source on GitHub ↗
(typ MessageType, p []byte)

Source from the content-addressed store, hash-verified

211}
212
213func (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

Callers 2

WriteMethod · 0.95
ReadMethod · 0.45

Calls 3

isClosedMethod · 0.95
SendBytesMethod · 0.80
SendTextMethod · 0.80

Tested by

no test coverage detected