WritePreparedMessage writes prepared message into connection.
(pm *PreparedMessage)
| 733 | |
| 734 | // WritePreparedMessage writes prepared message into connection. |
| 735 | func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error { |
| 736 | frameType, frameData, err := pm.frame(prepareKey{ |
| 737 | isServer: c.isServer, |
| 738 | compress: c.newCompressionWriter != nil && c.enableWriteCompression && isData(pm.messageType), |
| 739 | compressionLevel: c.compressionLevel, |
| 740 | }) |
| 741 | if err != nil { |
| 742 | return err |
| 743 | } |
| 744 | if c.isWriting { |
| 745 | panic("concurrent write to websocket connection") |
| 746 | } |
| 747 | c.isWriting = true |
| 748 | err = c.write(frameType, c.writeDeadline, frameData, nil) |
| 749 | if !c.isWriting { |
| 750 | panic("concurrent write to websocket connection") |
| 751 | } |
| 752 | c.isWriting = false |
| 753 | return err |
| 754 | } |
| 755 | |
| 756 | // WriteMessage is a helper method for getting a writer using NextWriter, |
| 757 | // writing the message and closing the writer. |