MCPcopy
hub / github.com/deepstreamIO/deepstream.io / process

Method process

src/utils/message-processor.ts:34–75  ·  view source on GitHub ↗

* This method is the way the message processor accepts input. It receives arrays * of parsed messages, iterates through them and issues permission requests for * each individual message * * @todo The responses from the permission service might arrive in any arbitrary order - order them

(socketWrapper: SocketWrapper, parsedMessages: Message[])

Source from the content-addressed store, hash-verified

32 * @todo Handle permission handler timeouts
33 */
34 public process (socketWrapper: SocketWrapper, parsedMessages: Message[]): void {
35 const length = parsedMessages.length
36 for (let i = 0; i < length; i++) {
37 const message = parsedMessages[i]
38
39 if (message.topic === TOPIC.CONNECTION && message.action === CONNECTION_ACTION.PING) {
40 // respond to PING message
41 socketWrapper.sendMessage({ topic: TOPIC.CONNECTION, action: CONNECTION_ACTION.PONG })
42 continue
43 }
44
45 if (message.names && message.names.length > 0) {
46 const uuid = getUid()
47
48 if (this.bulkResults.has(uuid)) {
49 this.services.logger.error(EVENT.NOT_VALID_UUID, `Invalid uuid used twice ${uuid}`, { uuid })
50 }
51
52 this.bulkResults.set(uuid, {
53 total: message.names!.length,
54 completed: 0
55 })
56 const l = message.names!.length
57 for (let j = 0; j < l; j++) {
58 this.services.permission.canPerformAction(
59 socketWrapper,
60 { ...message, name: message.names![j] },
61 this.onBulkPermissionResponse,
62 { originalMessage: message, uuid }
63 )
64 }
65 continue
66 }
67
68 this.services.permission.canPerformAction(
69 socketWrapper,
70 message,
71 this.onPermissionResponse,
72 {}
73 )
74 }
75 }
76
77 private onBulkPermissionResponse (socketWrapper: SocketWrapper, message: Message, passItOn: any, error: ALL_ACTIONS | Error | string | null, result: boolean) {
78 const bulkResult = this.bulkResults.get(passItOn.uuid)!

Callers 1

Calls 6

getUidFunction · 0.90
sendMessageMethod · 0.45
hasMethod · 0.45
errorMethod · 0.45
setMethod · 0.45
canPerformActionMethod · 0.45

Tested by

no test coverage detected