(status int, payload string)
| 725 | } |
| 726 | |
| 727 | func (nc *Conn) wsEnqueueCloseMsgLocked(status int, payload string) { |
| 728 | wr, ok := nc.bw.w.(*websocketWriter) |
| 729 | if !ok || wr.cmDone { |
| 730 | return |
| 731 | } |
| 732 | statusAndPayloadLen := 2 + len(payload) |
| 733 | frame := make([]byte, 2+4+statusAndPayloadLen) |
| 734 | n, key := wsFillFrameHeader(frame, false, wsCloseMessage, statusAndPayloadLen) |
| 735 | // Set the status |
| 736 | binary.BigEndian.PutUint16(frame[n:], uint16(status)) |
| 737 | // If there is a payload, copy |
| 738 | if len(payload) > 0 { |
| 739 | copy(frame[n+2:], payload) |
| 740 | } |
| 741 | // Mask status + payload |
| 742 | wsMaskBuf(key, frame[n:n+statusAndPayloadLen]) |
| 743 | wr.cm = frame |
| 744 | wr.cmDone = true |
| 745 | nc.bw.flush() |
| 746 | if c := wr.compressor; c != nil { |
| 747 | c.Close() |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | func (nc *Conn) wsEnqueueControlMsg(needsLock bool, frameType wsOpCode, payload []byte) { |
| 752 | // In some low-level unit tests it will happen... |
no test coverage detected