MCPcopy Create free account
hub / github.com/DeepNotesApp/DeepNotes / setup

Method setup

apps/realtime-server/src/sockets.ts:99–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97 }
98
99 async setup() {
100 if (this._setupPromise != null) {
101 return await this._setupPromise;
102 }
103
104 this._setupPromise = new Resolvable();
105
106 if (this.sessionId != null) {
107 let sessionInvalidated;
108
109 [this.userId, sessionInvalidated] = await Promise.all([
110 dataAbstraction().hget('session', this.sessionId, 'user-id'),
111
112 this._checkSessionInvalidated(),
113 ]);
114
115 if (this.userId == null || sessionInvalidated) {
116 this.destroySocket();
117 throw new Error('Invalid session.');
118 }
119
120 getSub().on('messageBuffer', this._handleUserNotification);
121
122 await getSub().subscribe(`user-notification:${this.userId}`);
123 }
124
125 this._setupPromise.resolve();
126 }
127
128 private _handleUserNotification = async (
129 channelBuffer: Buffer,

Callers 1

ws-server.tsFile · 0.45

Calls 3

destroySocketMethod · 0.95
hgetMethod · 0.45

Tested by

no test coverage detected