@@ -105,6 +105,7 @@ class localServer {
105105 keyID : '' ,
106106 key : ''
107107 } ] ;
108+ this . requestPool = new Map ( ) ;
108109 this . expressServer . set ( 'views' , Path . join ( __dirname , 'views' ) ) ;
109110 this . expressServer . set ( 'view engine' , 'pug' ) ;
110111 this . expressServer . use ( cookieParser ( ) ) ;
@@ -149,6 +150,13 @@ class localServer {
149150 }
150151 } ) ;
151152 }
153+ catchCmd ( mail , uuid ) {
154+ const socket = this . requestPool . get ( uuid ) ;
155+ if ( ! socket ) {
156+ return console . log ( `Get cmd that have no matched socket \n\n` , mail ) ;
157+ }
158+ socket . emit ( 'doingRequest' , mail , uuid ) ;
159+ }
152160 tryConnectCoNET ( socket , sessionHash ) {
153161 console . log ( `doing tryConnectCoNET` ) ;
154162 // have CoGate connect
@@ -177,14 +185,6 @@ class localServer {
177185 }
178186 }
179187 } ;
180- /**
181- *
182- * @param cmd CoNET server command
183- *
184- */
185- const catchUnSerialCmd = ( cmd ) => {
186- return console . log ( `catchUnSerialCmd: LocalWebServer catch UnSerialCmd!\n\ncmd` ) ;
187- } ;
188188 const makeConnect = ( sendMail ) => {
189189 if ( ! this . imapConnectData . sendToQTGate || sendMail ) {
190190 this . imapConnectData . sendToQTGate = true ;
@@ -198,14 +198,14 @@ class localServer {
198198 this . socketServer . emit ( 'systemErr' , err ) ;
199199 return socket . emit ( 'tryConnectCoNETStage' , imapErrorCallBack ( err . message ) ) ;
200200 }
201- return this . CoNETConnectCalss = new coNETConnect_1 . default ( this . imapConnectData , this . socketServer , this . openPgpKeyOption , true , mail => {
202- return catchUnSerialCmd ( mail ) ;
201+ return this . CoNETConnectCalss = new coNETConnect_1 . default ( this . imapConnectData , this . socketServer , this . openPgpKeyOption , true , ( mail , uuid ) => {
202+ return this . catchCmd ( mail , uuid ) ;
203203 } , _exitFunction ) ;
204204 } ) ;
205205 }
206206 console . log ( `makeConnect without sendMail` ) ;
207- return this . CoNETConnectCalss = new coNETConnect_1 . default ( this . imapConnectData , this . socketServer , this . openPgpKeyOption , false , mail => {
208- return catchUnSerialCmd ( mail ) ;
207+ return this . CoNETConnectCalss = new coNETConnect_1 . default ( this . imapConnectData , this . socketServer , this . openPgpKeyOption , false , ( mail , uuid ) => {
208+ return this . catchCmd ( mail , uuid ) ;
209209 } , _exitFunction ) ;
210210 } ;
211211 if ( ! this . CoNETConnectCalss || this . CoNETConnectCalss . alreadyExit ) {
@@ -323,7 +323,8 @@ class localServer {
323323 } ) ;
324324 } ) ;
325325 socket . on ( 'doingRequest' , ( uuid , request , CallBack ) => {
326- console . log ( `on doingRequest\n[ ${ uuid } ]\n${ request } ` ) ;
326+ this . requestPool . set ( uuid , socket ) ;
327+ saveLog ( `doingRequest on ${ uuid } ` ) ;
327328 return this . CoNETConnectCalss . requestCoNET_v1 ( uuid , request , CallBack ) ;
328329 } ) ;
329330 }
0 commit comments