fix(communication): send ready event when both sides are ready

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-06-28 19:25:16 +02:00
parent e6b9afc686
commit f4a1999a8b
11 changed files with 271 additions and 142 deletions

View file

@ -135,7 +135,7 @@ export const EditorPane: React.FC<EditorPaneProps> = ({ scrollState, onScroll, o
const mayEdit = useMayEdit()
useEffect(() => {
const listener = messageTransporter.doAsSoonAsConnected(() => messageTransporter.sendReady())
const listener = messageTransporter.doAsSoonAsConnected(() => messageTransporter.startSendingOfReadyRequests())
return () => {
listener.off()
}

View file

@ -89,9 +89,9 @@ describe('frontend websocket', () => {
it('can send messages', () => {
mockSocket()
const value: Message<MessageType> = { type: MessageType.READY }
const value: Message<MessageType> = { type: MessageType.READY_REQUEST }
adapter.send(value)
expect(sendSpy).toHaveBeenCalledWith('{"type":"READY"}')
expect(sendSpy).toHaveBeenCalledWith('{"type":"READY_REQUEST"}')
})
it('can read the connection state when open', () => {