answer the pending question request and resolve the answer
(
requestId: string,
answer: string,
isCustomAnswer = false,
)
| 76 | |
| 77 | /**answer the pending question request and resolve the answer */ |
| 78 | answerQuestion( |
| 79 | requestId: string, |
| 80 | answer: string, |
| 81 | isCustomAnswer = false, |
| 82 | ): boolean { |
| 83 | const pending = this.pendingRequests.get(requestId); |
| 84 | if (!pending) { |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | this.pendingRequests.delete(requestId); |
| 89 | this.currentState.pendingQuestion = null; |
| 90 | |
| 91 | const event: QuestionAnsweredEvent = { |
| 92 | requestId, |
| 93 | answer, |
| 94 | isCustomAnswer, |
| 95 | }; |
| 96 | |
| 97 | this.emit("questionAnswered", event); |
| 98 | pending.resolve(answer); |
| 99 | |
| 100 | return true; |
| 101 | } |
| 102 | |
| 103 | async initialize(): Promise<QuizServiceState> { |
| 104 | this.currentState = { |
no test coverage detected