File tree Expand file tree Collapse file tree 9 files changed +66
-26
lines changed Expand file tree Collapse file tree 9 files changed +66
-26
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ import (
1111)
1212
1313const (
14- writeWait = 60 * time .Second
15- pongWait = 60 * time .Second
14+ writeWait = 30 * time .Second
15+ pongWait = 30 * time .Second
1616 pingPeriod = (pongWait * 9 ) / 10
1717)
1818
Original file line number Diff line number Diff line change @@ -98,11 +98,16 @@ func (s *LendingMarketsSocket) Unsubscribe(c *Client) {
9898 }
9999}
100100
101- // BroadcastMessage streams message to all the subscriptions subscribed to the pair
102- func (s * LendingMarketsSocket ) BroadcastMessage (channelID string , p interface {}) error {
101+ func (s * LendingMarketsSocket ) getSubscriptions () map [string ]map [* Client ]bool {
103102 s .subsMutex .RLock ()
104103 defer s .subsMutex .RUnlock ()
105- for c , status := range s .subscriptions [channelID ] {
104+ return s .subscriptions
105+ }
106+
107+ // BroadcastMessage streams message to all the subscriptions subscribed to the pair
108+ func (s * LendingMarketsSocket ) BroadcastMessage (channelID string , p interface {}) error {
109+ subs := s .getSubscriptions ()
110+ for c , status := range subs [channelID ] {
106111 if status {
107112 s .SendUpdateMessage (c , p )
108113 }
Original file line number Diff line number Diff line change @@ -101,11 +101,16 @@ func (s *LendingOrderBookSocket) Unsubscribe(c *Client) {
101101 }
102102}
103103
104- // BroadcastMessage streams message to all the subscribtions subscribed to the pair
105- func (s * LendingOrderBookSocket ) BroadcastMessage (channelID string , p interface {}) error {
104+ func (s * LendingOrderBookSocket ) getSubscriptions () map [string ]map [* Client ]bool {
106105 s .subsMutex .RLock ()
107106 defer s .subsMutex .RUnlock ()
108- for c , status := range s .subscriptions [channelID ] {
107+ return s .subscriptions
108+ }
109+
110+ // BroadcastMessage streams message to all the subscribtions subscribed to the pair
111+ func (s * LendingOrderBookSocket ) BroadcastMessage (channelID string , p interface {}) error {
112+ subs := s .getSubscriptions ()
113+ for c , status := range subs [channelID ] {
109114 if status {
110115 s .SendUpdateMessage (c , p )
111116 }
Original file line number Diff line number Diff line change @@ -94,11 +94,16 @@ func (s *LendingPriceBoardSocket) Unsubscribe(c *Client) {
9494 }
9595}
9696
97- // BroadcastMessage streams message to all the subscriptions subscribed to the pair
98- func (s * LendingPriceBoardSocket ) BroadcastMessage (channelID string , p interface {}) error {
97+ func (s * LendingPriceBoardSocket ) getSubscriptions () map [string ]map [* Client ]bool {
9998 s .subsMutex .RLock ()
10099 defer s .subsMutex .RUnlock ()
101- for c , status := range s .subscriptions [channelID ] {
100+ return s .subscriptions
101+ }
102+
103+ // BroadcastMessage streams message to all the subscriptions subscribed to the pair
104+ func (s * LendingPriceBoardSocket ) BroadcastMessage (channelID string , p interface {}) error {
105+ subs := s .getSubscriptions ()
106+ for c , status := range subs [channelID ] {
102107 if status {
103108 s .SendUpdateMessage (c , p )
104109 }
Original file line number Diff line number Diff line change @@ -97,12 +97,17 @@ func (s *LendingTradeSocket) Unsubscribe(c *Client) {
9797 }
9898}
9999
100+ func (s * LendingTradeSocket ) getSubscriptions () map [string ]map [* Client ]bool {
101+ s .subsMutex .RLock ()
102+ defer s .subsMutex .RUnlock ()
103+ return lendingTradeSocket .subscriptions
104+ }
105+
100106// BroadcastMessage broadcasts trade message to all subscribed sockets
101107func (s * LendingTradeSocket ) BroadcastMessage (channelID string , p interface {}) {
102108 go func () {
103- s .subsMutex .RLock ()
104- defer s .subsMutex .RUnlock ()
105- for conn , active := range lendingTradeSocket .subscriptions [channelID ] {
109+ subs := s .getSubscriptions ()
110+ for conn , active := range subs [channelID ] {
106111 if active {
107112 s .SendUpdateMessage (conn , p )
108113 }
Original file line number Diff line number Diff line change @@ -96,11 +96,16 @@ func (s *MarketsSocket) Unsubscribe(c *Client) {
9696 }
9797}
9898
99- // BroadcastMessage streams message to all the subscriptions subscribed to the pair
100- func (s * MarketsSocket ) BroadcastMessage (channelID string , p interface {}) error {
99+ func (s * MarketsSocket ) getSubscriptions () map [string ]map [* Client ]bool {
101100 s .subsMutex .RLock ()
102101 defer s .subsMutex .RUnlock ()
103- for c , status := range s .subscriptions [channelID ] {
102+ return s .subscriptions
103+ }
104+
105+ // BroadcastMessage streams message to all the subscriptions subscribed to the pair
106+ func (s * MarketsSocket ) BroadcastMessage (channelID string , p interface {}) error {
107+ subs := s .getSubscriptions ()
108+ for c , status := range subs [channelID ] {
104109 if status {
105110 s .SendUpdateMessage (c , p )
106111 }
Original file line number Diff line number Diff line change @@ -98,11 +98,16 @@ func (s *OrderBookSocket) Unsubscribe(c *Client) {
9898 }
9999}
100100
101- // BroadcastMessage streams message to all the subscribtions subscribed to the pair
102- func (s * OrderBookSocket ) BroadcastMessage (channelID string , p interface {}) error {
101+ func (s * OrderBookSocket ) getSubscriptions () map [string ]map [* Client ]bool {
103102 s .subsMutex .RLock ()
104103 defer s .subsMutex .RUnlock ()
105- for c , status := range s .subscriptions [channelID ] {
104+ return s .subscriptions
105+ }
106+
107+ // BroadcastMessage streams message to all the subscribtions subscribed to the pair
108+ func (s * OrderBookSocket ) BroadcastMessage (channelID string , p interface {}) error {
109+ subs := s .getSubscriptions ()
110+ for c , status := range subs [channelID ] {
106111 if status {
107112 s .SendUpdateMessage (c , p )
108113 }
Original file line number Diff line number Diff line change @@ -95,11 +95,16 @@ func (s *PriceBoardSocket) Unsubscribe(c *Client) {
9595 }
9696}
9797
98- // BroadcastMessage streams message to all the subscriptions subscribed to the pair
99- func (s * PriceBoardSocket ) BroadcastMessage (channelID string , p interface {}) error {
98+ func (s * PriceBoardSocket ) getSubscriptions () map [string ]map [* Client ]bool {
10099 s .subsMutex .RLock ()
101100 defer s .subsMutex .RUnlock ()
102- for c , status := range s .subscriptions [channelID ] {
101+ return s .subscriptions
102+ }
103+
104+ // BroadcastMessage streams message to all the subscriptions subscribed to the pair
105+ func (s * PriceBoardSocket ) BroadcastMessage (channelID string , p interface {}) error {
106+ subs := s .getSubscriptions ()
107+ for c , status := range subs [channelID ] {
103108 if status {
104109 s .SendUpdateMessage (c , p )
105110 }
Original file line number Diff line number Diff line change @@ -93,12 +93,17 @@ func (s *TradeSocket) Unsubscribe(c *Client) {
9393 }
9494}
9595
96+ func (s * TradeSocket ) getSubscriptions () map [string ]map [* Client ]bool {
97+ s .subsMutex .RLock ()
98+ defer s .subsMutex .RUnlock ()
99+ return tradeSocket .subscriptions
100+ }
101+
96102// BroadcastMessage broadcasts trade message to all subscribed sockets
97103func (s * TradeSocket ) BroadcastMessage (channelID string , p interface {}) {
98104 go func () {
99- s .subsMutex .RLock ()
100- defer s .subsMutex .RUnlock ()
101- for conn , active := range tradeSocket .subscriptions [channelID ] {
105+ subs := s .getSubscriptions ()
106+ for conn , active := range subs [channelID ] {
102107 if active {
103108 s .SendUpdateMessage (conn , p )
104109 }
You can’t perform that action at this time.
0 commit comments