binance: add listenKeyExpired callback

This commit is contained in:
c9s 2022-09-11 14:10:30 +08:00
parent 4890d19ebf
commit ff635195fb
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 18 additions and 0 deletions

View File

@ -62,6 +62,8 @@ type Stream struct {
accountUpdateEventCallbacks []func(e *AccountUpdateEvent) accountUpdateEventCallbacks []func(e *AccountUpdateEvent)
accountConfigUpdateEventCallbacks []func(e *AccountConfigUpdateEvent) accountConfigUpdateEventCallbacks []func(e *AccountConfigUpdateEvent)
listenKeyExpiredCallbacks []func(e *ListenKeyExpired)
depthBuffers map[string]*depth.Buffer depthBuffers map[string]*depth.Buffer
} }
@ -363,6 +365,10 @@ func (s *Stream) dispatchEvent(e interface{}) {
case *AccountConfigUpdateEvent: case *AccountConfigUpdateEvent:
s.EmitAccountConfigUpdateEvent(e) s.EmitAccountConfigUpdateEvent(e)
case *ListenKeyExpired:
s.EmitListenKeyExpired(e)
} }
} }

View File

@ -154,6 +154,16 @@ func (s *Stream) EmitAccountConfigUpdateEvent(e *AccountConfigUpdateEvent) {
} }
} }
func (s *Stream) OnListenKeyExpired(cb func(e *ListenKeyExpired)) {
s.listenKeyExpiredCallbacks = append(s.listenKeyExpiredCallbacks, cb)
}
func (s *Stream) EmitListenKeyExpired(e *ListenKeyExpired) {
for _, cb := range s.listenKeyExpiredCallbacks {
cb(e)
}
}
type StreamEventHub interface { type StreamEventHub interface {
OnDepthEvent(cb func(e *DepthEvent)) OnDepthEvent(cb func(e *DepthEvent))
@ -184,4 +194,6 @@ type StreamEventHub interface {
OnAccountUpdateEvent(cb func(e *AccountUpdateEvent)) OnAccountUpdateEvent(cb func(e *AccountUpdateEvent))
OnAccountConfigUpdateEvent(cb func(e *AccountConfigUpdateEvent)) OnAccountConfigUpdateEvent(cb func(e *AccountConfigUpdateEvent))
OnListenKeyExpired(cb func(e *ListenKeyExpired))
} }