(msg: string, params: any, con: MessageConnect)
| 171 | } |
| 172 | |
| 173 | private connectHandle(msg: string, params: any, con: MessageConnect) { |
| 174 | const func = this.apiFunctionMap.get(msg); |
| 175 | if (func) { |
| 176 | const ret = func(params, new SenderConnect(con)); |
| 177 | if (ret) { |
| 178 | if (ret instanceof Promise) { |
| 179 | ret |
| 180 | .then((data) => { |
| 181 | data && con.sendMessage({ code: 0, data }); |
| 182 | }) |
| 183 | .catch((e: Error) => { |
| 184 | con.sendMessage({ code: -1, message: formatErrorToClient(e) }); |
| 185 | this.logger.error("connectHandle error", Logger.E(e)); |
| 186 | }); |
| 187 | return true; |
| 188 | } else { |
| 189 | con.sendMessage({ code: 0, data: ret }); |
| 190 | } |
| 191 | } |
| 192 | return true; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | private messageHandle( |
| 197 | action: string, |
no test coverage detected