mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-23 03:11:35 +00:00
minor cleanup
This commit is contained in:
parent
1e346aaad0
commit
b582c444f8
@ -158,18 +158,13 @@ func (c *Conn) _getDeadlineCancellation(t *time.Time) (util.Cancellation, bool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetReadCallback sets a callback which will be called whenever a packet is received.
|
// SetReadCallback sets a callback which will be called whenever a packet is received.
|
||||||
// Note that calls to Read will fail if the callback has been set to a non-nil value.
|
|
||||||
func (c *Conn) SetReadCallback(callback func([]byte)) {
|
func (c *Conn) SetReadCallback(callback func([]byte)) {
|
||||||
c.EnqueueFrom(nil, func() {
|
c.EnqueueFrom(nil, func() {
|
||||||
c._setReadCallback(callback)
|
c.readCallback = callback
|
||||||
|
c._drainReadBuffer()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) _setReadCallback(callback func([]byte)) {
|
|
||||||
c.readCallback = callback
|
|
||||||
c._drainReadBuffer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Conn) _drainReadBuffer() {
|
func (c *Conn) _drainReadBuffer() {
|
||||||
if c.readCallback == nil {
|
if c.readCallback == nil {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user