Send sends a message to the frontend (i.e. the client). The message is buffered until Flush is called. Any error encountered will be returned from Flush.
(msg BackendMessage)
| 59 | // Send sends a message to the frontend (i.e. the client). The message is buffered until Flush is called. Any error |
| 60 | // encountered will be returned from Flush. |
| 61 | func (b *Backend) Send(msg BackendMessage) { |
| 62 | if b.encodeError != nil { |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | prevLen := len(b.wbuf) |
| 67 | newBuf, err := msg.Encode(b.wbuf) |
| 68 | if err != nil { |
| 69 | b.encodeError = err |
| 70 | return |
| 71 | } |
| 72 | b.wbuf = newBuf |
| 73 | |
| 74 | if b.tracer != nil { |
| 75 | b.tracer.traceMessage('B', int32(len(b.wbuf)-prevLen), msg) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | // Flush writes any pending messages to the frontend (i.e. the client). |
| 80 | func (b *Backend) Flush() error { |