* Dispatch a text-protocol message. * Mirrors: ibapi/decoder.py interpret()
(fields: string[], msgId?: number)
| 40 | * Mirrors: ibapi/decoder.py interpret() |
| 41 | */ |
| 42 | interpret(fields: string[], msgId?: number): void { |
| 43 | if (msgId === undefined) { |
| 44 | msgId = parseInt(fields[0] || '0', 10) |
| 45 | } |
| 46 | if (msgId === 0) return |
| 47 | |
| 48 | const handler = this.msgId2textHandler.get(msgId) |
| 49 | if (!handler) { |
| 50 | this.wrapper.error(NO_VALID_ID, currentTimeMillis(), UNKNOWN_ID.code(), UNKNOWN_ID.msg(), '') |
| 51 | return |
| 52 | } |
| 53 | |
| 54 | try { |
| 55 | handler(this, fields[Symbol.iterator]()) |
| 56 | } catch (e) { |
| 57 | if (e instanceof BadMessage) { |
| 58 | this.wrapper.error( |
| 59 | NO_VALID_ID, currentTimeMillis(), |
| 60 | BAD_MESSAGE.code(), BAD_MESSAGE.msg() + fields.join(','), '', |
| 61 | ) |
| 62 | } |
| 63 | throw e |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Dispatch a protobuf-encoded message. |