()
| 544 | }; |
| 545 | |
| 546 | async sendInitialMessage() { |
| 547 | const { inflightRequests } = this.state; |
| 548 | invariant( |
| 549 | inflightRequests, |
| 550 | 'inflightRequests falsey inside sendInitialMessage', |
| 551 | ); |
| 552 | const messageID = this.nextClientMessageID++; |
| 553 | |
| 554 | const shouldSendInitialPlatformDetails = !_isEqual( |
| 555 | this.props.lastCommunicatedPlatformDetails, |
| 556 | )(getConfig().platformDetails); |
| 557 | |
| 558 | const clientResponses: ClientClientResponse[] = []; |
| 559 | if (shouldSendInitialPlatformDetails) { |
| 560 | clientResponses.push({ |
| 561 | type: serverRequestTypes.PLATFORM_DETAILS, |
| 562 | platformDetails: getConfig().platformDetails, |
| 563 | }); |
| 564 | } |
| 565 | |
| 566 | let activityUpdatePromise; |
| 567 | const { queuedActivityUpdates } = this.props.connection; |
| 568 | if (queuedActivityUpdates.length > 0) { |
| 569 | clientResponses.push({ |
| 570 | type: serverRequestTypes.INITIAL_ACTIVITY_UPDATES, |
| 571 | activityUpdates: queuedActivityUpdates, |
| 572 | }); |
| 573 | activityUpdatePromise = |
| 574 | inflightRequests.fetchResponse<ActivityUpdateResponseServerSocketMessage>( |
| 575 | messageID, |
| 576 | serverSocketMessageTypes.ACTIVITY_UPDATE_RESPONSE, |
| 577 | ); |
| 578 | } |
| 579 | |
| 580 | const sessionState = this.props.sessionStateFunc(); |
| 581 | const { sessionIdentification } = this.props; |
| 582 | const initialMessage = { |
| 583 | type: clientSocketMessageTypes.INITIAL, |
| 584 | id: messageID, |
| 585 | payload: { |
| 586 | clientResponses, |
| 587 | sessionState, |
| 588 | sessionIdentification, |
| 589 | }, |
| 590 | }; |
| 591 | this.initializedWithUserState = this.props.preRequestUserState; |
| 592 | this.sendMessage(initialMessage); |
| 593 | |
| 594 | const stateSyncPromise = |
| 595 | inflightRequests.fetchResponse<ClientStateSyncServerSocketMessage>( |
| 596 | messageID, |
| 597 | serverSocketMessageTypes.STATE_SYNC, |
| 598 | ); |
| 599 | |
| 600 | // https://flow.org/try/#1N4Igxg9gdgZglgcxALlAJwKYEMwBcD6aArlLnALYYrgA2WAzvXGCADQgYAeOBARgJ74AJhhhYiNXClzEM7DFCLl602QF92kEdQb8oYAAQwSeONAMAHNBHJx6GAII0aAHgAqyA8AMBqANoA1hj8nvQycFAIALqetpwYQgZqAHwAFAA6UAYGERZEuJ4AJABK2EIA8lA0-O7JrJkAlJ4ACta29i6F5bwAVgCyWBburAa4-BYYEDAGhVgA7lhwuMnJXpnZkFBhlm12GPQGALwGflEA3OsGm9tB-AfH3T0YeAB0t-SpufkNF1lGEGgDKkaBhcDkjgYAAxncEuAzvF4gyK4AAWMLgPh8DTWfw20BuwQh7z8cHOlzxWzBVhsewhX1wgWCZNxOxp9noLzy9BRqWp7QwP0uaku1zBmHoElw9wM80WYNabIwLywzl5u3Zgr+ooMAgAclhKJ5gH4wmgItFYnB4kI1BDgGpftkYACgSCwXAIdDYfDghykQhUejMdjgOSrviwbcib6Sczstk9QaMIz+FEIeLJfRY46kpdMLgiGgsonKL9hVBMrp9EYTGRzPYoEIAJJQJZwFV9fb0LAIDCpEOXN2jfa4BX8nNwaYZEAojDOCDpEAvMJYNBSgDqSx5i4Ci4aA5ZuBHY9pxxP9he4ogNAAbn2ZEQBTny5dZUtWfynDRUt4j2FzxgSSamobAgHeaBMNA1A3pCLwAEwAIwACwvJCIBqEAA |
| 601 | // $FlowFixMe fixed in Flow 0.214 |
| 602 | const { stateSyncMessage, activityUpdateMessage } = await promiseAll({ |
| 603 | activityUpdateMessage: activityUpdatePromise, |
no test coverage detected