Handle disconnect for new subscription and unsubscribe accordingly
parent
ac1465d091
commit
42ec06d06c
|
@ -765,7 +765,7 @@ The websocket interface provides the following requests:
|
|||
The client can subscribe to the following events:
|
||||
|
||||
- `subscribeNewBlock` - new block added to blockchain
|
||||
- `subscribeNewTransaction` - new transaction added to blockchain (mempool for all addresses)
|
||||
- `subscribeNewTransaction` - new transaction added to blockchain (all addresses)
|
||||
- `subscribeAddresses` - new transaction for given address (list of addresses)
|
||||
- `subscribeFiatRates` - new currency rate ticker
|
||||
|
||||
|
|
|
@ -246,6 +246,7 @@ func (s *WebsocketServer) onConnect(c *websocketChannel) {
|
|||
|
||||
func (s *WebsocketServer) onDisconnect(c *websocketChannel) {
|
||||
s.unsubscribeNewBlock(c)
|
||||
s.unsubscribeNewTransaction(c)
|
||||
s.unsubscribeAddresses(c)
|
||||
s.unsubscribeFiatRates(c)
|
||||
glog.Info("Client disconnected ", c.id, ", ", c.ip)
|
||||
|
@ -684,7 +685,6 @@ func (s *WebsocketServer) unsubscribeNewBlock(c *websocketChannel) (res interfac
|
|||
func (s *WebsocketServer) subscribeNewTransaction(c *websocketChannel, req *websocketReq) (res interface{}, err error) {
|
||||
s.newTransactionSubscriptionsLock.Lock()
|
||||
defer s.newTransactionSubscriptionsLock.Unlock()
|
||||
glog.Infof("subscribeNewTransaction: %+v\n%v\n", c, req.ID)
|
||||
s.newTransactionSubscriptions[c] = req.ID
|
||||
return &subscriptionResponse{true}, nil
|
||||
}
|
||||
|
@ -692,7 +692,6 @@ func (s *WebsocketServer) subscribeNewTransaction(c *websocketChannel, req *webs
|
|||
func (s *WebsocketServer) unsubscribeNewTransaction(c *websocketChannel) (res interface{}, err error) {
|
||||
s.newTransactionSubscriptionsLock.Lock()
|
||||
defer s.newTransactionSubscriptionsLock.Unlock()
|
||||
glog.Infof("unsubscribeNewTransaction: %+v\n", c)
|
||||
delete(s.newTransactionSubscriptions, c)
|
||||
return &subscriptionResponse{false}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue