MCPcopy
hub / github.com/coder/websocket / nextMessage

Method nextMessage

internal/examples/chat/chat_test.go:232–243  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230}
231
232func (cl *client) nextMessage() (string, error) {
233 typ, b, err := cl.c.Read(context.Background())
234 if err != nil {
235 return "", err
236 }
237
238 if typ != websocket.MessageText {
239 cl.c.Close(websocket.StatusUnsupportedData, "expected text message")
240 return "", fmt.Errorf("expected text message but got %v", typ)
241 }
242 return string(b), nil
243}
244
245func (cl *client) Close() error {
246 return cl.c.Close(websocket.StatusNormalClosure, "")

Callers 2

Test_chatServerFunction · 0.80
testAllMessagesReceivedFunction · 0.80

Calls 2

ReadMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected