SetOnRequest initialize ctx when setting OnRequest.
(onRequest OnRequest)
| 64 | |
| 65 | // SetOnRequest initialize ctx when setting OnRequest. |
| 66 | func (c *connection) SetOnRequest(onRequest OnRequest) error { |
| 67 | if onRequest == nil { |
| 68 | return nil |
| 69 | } |
| 70 | c.onRequestCallback.Store(onRequest) |
| 71 | // fix: trigger OnRequest if there is already input data. |
| 72 | if !c.inputBuffer.IsEmpty() { |
| 73 | c.onRequest() |
| 74 | } |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | // AddCloseCallback adds a CloseCallback to this connection. |
| 79 | func (c *connection) AddCloseCallback(callback CloseCallback) error { |