File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ const EventHandlerError = require('./event-handler-error');
1313const { EventHandlerErrorCode } = require ( '../common/result-code' ) ;
1414const BlockchainEvent = require ( './blockchain-event' ) ;
1515
16+ const CHANNEL_ID_RANDOM_NUMBER_RANGE = 1000 ;
17+
1618class EventChannelManager {
1719 constructor ( node ) {
1820 this . node = node ;
@@ -107,7 +109,9 @@ class EventChannelManager {
107109 `The number of event channels exceeds its limit ` +
108110 `(${ NodeConfigs . MAX_NUM_EVENT_CHANNELS } )` ) ;
109111 }
110- const channelId = Date . now ( ) ; // NOTE: Only used in blockchain
112+ // NOTE: Only used in blockchain
113+ const channelId
114+ = String ( Date . now ( ) + Math . floor ( Math . random ( ) * CHANNEL_ID_RANDOM_NUMBER_RANGE ) ) ;
111115 if ( this . channels [ channelId ] ) { // TODO(cshcomcom): Retry logic.
112116 webSocket . terminate ( ) ;
113117 throw new EventHandlerError ( EventHandlerErrorCode . DUPLICATED_CHANNEL_ID ,
You can’t perform that action at this time.
0 commit comments