Skip to content

Commit 78ce34a

Browse files
committed
20191006
1 parent b6f2645 commit 78ce34a

18 files changed

+1523
-457
lines changed

app/CoNET.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ interface imapData {
165165
}
166166

167167
interface requestPoolData {
168-
CallBack: ( err?: Error, returnData?: any ) => void
168+
169169
timeout: any
170170
}
171171

@@ -282,7 +282,7 @@ interface QTGateAPIRequestCommand {
282282
account?: string
283283
error: number
284284
requestSerial?: string
285-
Args: any[]
285+
Args: any
286286
fingerprint?: string
287287
dataTransfer?: iTransferData
288288
requestTimes?: number

app/localWebServer.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

app/localWebServer.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,23 @@ export default class localServer {
124124
keyID:'',
125125
key: ''
126126
}]
127+
128+
private requestPool: Map < string, SocketIO.Socket > = new Map()
129+
130+
131+
private catchCmd ( mail: string, uuid: string ) {
132+
const socket = this.requestPool.get ( uuid )
133+
if ( !socket ) {
134+
return console.log (`Get cmd that have no matched socket \n\n`, mail )
135+
}
136+
137+
socket.emit ( 'doingRequest', mail, uuid )
138+
}
127139

128140
private tryConnectCoNET ( socket: SocketIO.Socket, sessionHash: string ) {
129141
console.log (`doing tryConnectCoNET`)
130142
// have CoGate connect
131143

132-
133144
let sendMail = false
134145
const _exitFunction = err => {
135146
//console.trace ( `_exitFunction err =`, err )
@@ -160,14 +171,6 @@ export default class localServer {
160171

161172

162173
}
163-
/**
164-
*
165-
* @param cmd CoNET server command
166-
*
167-
*/
168-
const catchUnSerialCmd = ( cmd: string ) => {
169-
return console.log (`catchUnSerialCmd: LocalWebServer catch UnSerialCmd!\n\ncmd`)
170-
}
171174

172175
const makeConnect = ( sendMail: boolean ) => {
173176

@@ -184,15 +187,15 @@ export default class localServer {
184187
return socket.emit ( 'tryConnectCoNETStage', imapErrorCallBack ( err.message ))
185188
}
186189

187-
return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, true, mail => {
188-
return catchUnSerialCmd ( mail )
190+
return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, true, ( mail, uuid ) => {
191+
return this.catchCmd ( mail, uuid )
189192
}, _exitFunction )
190193
})
191194

192195
}
193196
console.log ( `makeConnect without sendMail`)
194-
return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, false, mail => {
195-
return catchUnSerialCmd ( mail )
197+
return this.CoNETConnectCalss = new CoNETConnectCalss ( this.imapConnectData, this.socketServer, this.openPgpKeyOption, false, ( mail, uuid ) => {
198+
return this.catchCmd ( mail, uuid )
196199
}, _exitFunction )
197200

198201
}
@@ -334,7 +337,9 @@ export default class localServer {
334337
})
335338

336339
socket.on ( 'doingRequest', ( uuid, request, CallBack ) => {
337-
console.log (`on doingRequest\n[ ${ uuid }]\n${ request }`)
340+
341+
this.requestPool.set ( uuid, socket )
342+
saveLog (`doingRequest on ${ uuid }`)
338343
return this.CoNETConnectCalss.requestCoNET_v1 ( uuid, request, CallBack )
339344
})
340345

app/public/css/page.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,3 +838,16 @@ ul.plan-features {
838838
{
839839
color:#e7bdbc!important
840840
}
841+
842+
843+
.loadingGetResponse::after {
844+
border-color: #ab9420d9 transparent transparent!important;
845+
}
846+
847+
.conetResponse::after {
848+
border-color: #36c576d9 transparent transparent!important;
849+
}
850+
851+
.buttonUnActive {
852+
background: #e0e1e288 none!important;
853+
}

app/public/scripts/CoSearch.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,6 @@ const googleVideoSearchClickResult = {
19871987
nextPage: '/search?q=%E9%83%AD%E6%96%87%E8%B2%B4&tbm=vid&ei=BMZ2XbubG46YaczJgcAN&start=10&sa=N&ved=0ahUKEwi7rYW42cTkAhUOTBoKHcxkANgQ8NMDCIMB'
19881988
}
19891989

1990-
19911990
module coSearch_layout {
19921991
export class coSearch {
19931992

0 commit comments

Comments
 (0)