(opChain *chain)
| 532 | } |
| 533 | |
| 534 | func (ws *Websocket) readMessage(opChain *chain) *WebsocketMessage { |
| 535 | wm := newEmptyWebsocketMessage(opChain) |
| 536 | |
| 537 | if !ws.setReadDeadline(opChain) { |
| 538 | return nil |
| 539 | } |
| 540 | |
| 541 | var err error |
| 542 | wm.typ, wm.content, err = ws.conn.ReadMessage() |
| 543 | |
| 544 | if err != nil { |
| 545 | closeErr, ok := err.(*websocket.CloseError) |
| 546 | if !ok { |
| 547 | opChain.fail(AssertionFailure{ |
| 548 | Type: AssertOperation, |
| 549 | Errors: []error{ |
| 550 | errors.New("failed to read from websocket"), |
| 551 | err, |
| 552 | }, |
| 553 | }) |
| 554 | return nil |
| 555 | } |
| 556 | |
| 557 | wm.typ = websocket.CloseMessage |
| 558 | wm.closeCode = closeErr.Code |
| 559 | wm.content = []byte(closeErr.Text) |
| 560 | } |
| 561 | |
| 562 | ws.printRead(wm.typ, wm.content, wm.closeCode) |
| 563 | |
| 564 | return wm |
| 565 | } |
| 566 | |
| 567 | func (ws *Websocket) writeMessage( |
| 568 | opChain *chain, typ int, content []byte, closeCode ...int, |
no test coverage detected