@@ -41,6 +41,7 @@ function AGServerSocket(id, server, socket, protocolVersion) {
41
41
this . outboundPreparedMessageCount = 0 ;
42
42
this . outboundSentMessageCount = 0 ;
43
43
44
+ this . createRequest = this . server . options . requestCreator || this . defaultRequestCreator ;
44
45
this . cloneData = this . server . options . cloneData ;
45
46
46
47
this . inboundMessageStream = new WritableConsumableStream ( ) ;
@@ -197,6 +198,10 @@ AGServerSocket.prototype._startBatchOnHandshake = function () {
197
198
} , this . batchOnHandshakeDuration ) ;
198
199
} ;
199
200
201
+ AGServerSocket . prototype . defaultRequestCreator = function ( socket , id , procedureName , data ) {
202
+ return new AGRequest ( socket , id , procedureName , data ) ;
203
+ } ;
204
+
200
205
// ---- Receiver logic ----
201
206
202
207
AGServerSocket . prototype . receiver = function ( receiverName ) {
@@ -616,7 +621,7 @@ AGServerSocket.prototype._processInboundPacket = async function (packet, message
616
621
this . socket . close ( HANDSHAKE_REJECTION_STATUS_CODE ) ;
617
622
return ;
618
623
}
619
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
624
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
620
625
await this . _processHandshakeRequest ( request ) ;
621
626
this . _procedureDemux . write ( eventName , request ) ;
622
627
return ;
@@ -635,7 +640,7 @@ AGServerSocket.prototype._processInboundPacket = async function (packet, message
635
640
return ;
636
641
}
637
642
// Let AGServer handle these events.
638
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
643
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
639
644
await this . _processAuthenticateRequest ( request ) ;
640
645
this . _procedureDemux . write ( eventName , request ) ;
641
646
return ;
@@ -664,7 +669,7 @@ AGServerSocket.prototype._processInboundPacket = async function (packet, message
664
669
this . emitError ( error ) ;
665
670
666
671
if ( isRPC ) {
667
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
672
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
668
673
request . error ( error ) ;
669
674
}
670
675
return ;
@@ -674,7 +679,7 @@ AGServerSocket.prototype._processInboundPacket = async function (packet, message
674
679
this . emitError ( error ) ;
675
680
676
681
if ( isRPC ) {
677
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
682
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
678
683
request . error ( error ) ;
679
684
}
680
685
return ;
@@ -688,7 +693,7 @@ AGServerSocket.prototype._processInboundPacket = async function (packet, message
688
693
this . emitError ( error ) ;
689
694
690
695
if ( isRPC ) {
691
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
696
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
692
697
request . error ( error ) ;
693
698
}
694
699
return ;
@@ -702,13 +707,13 @@ AGServerSocket.prototype._processInboundPacket = async function (packet, message
702
707
this . emitError ( error ) ;
703
708
704
709
if ( isRPC ) {
705
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
710
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
706
711
request . error ( error ) ;
707
712
}
708
713
return ;
709
714
}
710
715
if ( isRPC ) {
711
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
716
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
712
717
await this . _processUnsubscribeRequest ( request ) ;
713
718
this . _procedureDemux . write ( eventName , request ) ;
714
719
return ;
@@ -735,7 +740,7 @@ AGServerSocket.prototype._processInboundPacket = async function (packet, message
735
740
let newData ;
736
741
737
742
if ( isRPC ) {
738
- let request = new AGRequest ( this , packet . cid , eventName , packet . data ) ;
743
+ let request = this . createRequest ( this , packet . cid , eventName , packet . data ) ;
739
744
try {
740
745
let { data} = await this . server . _processMiddlewareAction ( this . middlewareInboundStream , action , this ) ;
741
746
newData = data ;
0 commit comments