diff --git a/pkg/types/standardstream_callbacks.go b/pkg/types/standardstream_callbacks.go index db33b748b..7777aba72 100644 --- a/pkg/types/standardstream_callbacks.go +++ b/pkg/types/standardstream_callbacks.go @@ -14,6 +14,16 @@ func (stream *StandardStream) EmitConnect() { } } +func (stream *StandardStream) OnDisconnect(cb func()) { + stream.disconnectCallbacks = append(stream.disconnectCallbacks, cb) +} + +func (stream *StandardStream) EmitDisconnect() { + for _, cb := range stream.disconnectCallbacks { + cb() + } +} + func (stream *StandardStream) OnTradeUpdate(cb func(trade Trade)) { stream.tradeUpdateCallbacks = append(stream.tradeUpdateCallbacks, cb) } @@ -97,6 +107,8 @@ func (stream *StandardStream) EmitBookSnapshot(book OrderBook) { type StandardStreamEventHub interface { OnConnect(cb func()) + OnDisconnect(cb func()) + OnTradeUpdate(cb func(trade Trade)) OnOrderUpdate(cb func(order Order)) diff --git a/pkg/types/stream.go b/pkg/types/stream.go index a811106ee..5a4f35423 100644 --- a/pkg/types/stream.go +++ b/pkg/types/stream.go @@ -25,6 +25,8 @@ type StandardStream struct { connectCallbacks []func() + disconnectCallbacks []func() + // private trade update callbacks tradeUpdateCallbacks []func(trade Trade)