Skip to content

Instantly share code, notes, and snippets.

@evan-brass
Created November 16, 2022 19:05
Show Gist options
  • Save evan-brass/9665ab2338640657714a7deca963ea71 to your computer and use it in GitHub Desktop.
Save evan-brass/9665ab2338640657714a7deca963ea71 to your computer and use it in GitHub Desktop.
Interface that will be provided by the network client:
export const peer_id = ""; // identifies this browser in the network
// Try_send and messages is how you would send sdp/ice candidates to signal your RTCPeerConnections.
export function try_send(peer_id, message) {} // Route a message through the network toward the peer. Unreliable since the peer could be offline or peers could fail in between.
const messages = new EventTarget(); // Receive messages from other peers.
// Would be used to join chatrooms:
export async function subscribe(topic_id) { [/* List of peers that have also subscribed to that topic */] }
export async function unsubscribe(topic) {}
// Not sure if this would be helpful for chat, but the network will also have K/V support eventually:
export async function lookup(hash) {}
export async function put(value) { /* put would return the hash that peers could use to retrieve the value. */}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment