Skip to content

Commit 9ffdc3b

Browse files
committed
Add reconnect token
1 parent 2cbc33b commit 9ffdc3b

File tree

1 file changed

+11
-0
lines changed
  • packages/app/src/app/overmind/effects/live

1 file changed

+11
-0
lines changed

packages/app/src/app/overmind/effects/live/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Options = {
3636

3737
type JoinChannelResponse = {
3838
liveUserId: string;
39+
reconnectToken: string;
3940
roomInfo: RoomInfo;
4041
};
4142

@@ -269,6 +270,16 @@ class Live {
269270
.join()
270271
.receive('ok', resp => {
271272
const result = camelizeKeys(resp) as JoinChannelResponse;
273+
274+
// We rewrite what our reconnect params are by adding the reconnect token.
275+
// This token makes sure that you can retain state between reconnects and restarts
276+
// from the server
277+
// @ts-ignore
278+
this.channel.joinPush.payload = () => ({
279+
version: 2,
280+
reconnect_token: result.reconnectToken,
281+
});
282+
272283
resolve(result);
273284
})
274285
.receive('error', resp => reject(camelizeKeys(resp)));

0 commit comments

Comments
 (0)