Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistence of sessions #2

Open
willwade opened this issue Oct 31, 2024 · 0 comments
Open

Persistence of sessions #2

willwade opened this issue Oct 31, 2024 · 0 comments

Comments

@willwade
Copy link
Contributor

on the display side we need to have a way of having a session more persistent eg

const sessionId = generateSessionToken(); /
localStorage.setItem("owdSessionId", sessionId);

then on load

const existingSessionId = localStorage.getItem("owdSessionId");
if (existingSessionId) {
    // Reconnect using the existing session ID
    reconnectToSession(existingSessionId);
}

we might need to do something like retain an active mapping of session tokens to device connections. This way, when a device reconnects, the server can match it with the correct peer. - but not sure how we would do this.

look at iceRestart

const offerOptions = { iceRestart: true };
const offer = await peerConnection.createOffer(offerOptions);
await peerConnection.setLocalDescription(offer);

oh also we would likely need to store other bits locally

const connectionDetails = {
    sessionId,
    signalingServer: "wss://your.signaling.server",
    webrtcConfig: { /* ICE servers, etc. */ },
};
localStorage.setItem("owdConnectionDetails", JSON.stringify(connectionDetails));
const savedDetails = localStorage.getItem("owdConnectionDetails");
if (savedDetails) {
    const { sessionId, signalingServer, webrtcConfig } = JSON.parse(savedDetails);
    reconnectToSession(sessionId, signalingServer, webrtcConfig);
}

All needs some careful thought and refactoring a bit..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant