()
| 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, |
no test coverage detected