Connecting to Session
Overview
A Session
is the main construct in Atm0s. Session is tie to a pair of room and peer, which are identified by an unique string.
Connect to a session
- Javascript
- React
const session = createSession("gateway_url",{
room: "my-room",
peer: "my-peer",
token: "some-token"
});
await session.connect();
<SessionProvider
gateways={["gateway_url"]}
room="my-room"
peer="my-peer"
token="some-token"
>
... streaming stuffs
</SessionProvider>
createSession
takes three arguments:
room
: the room name, this should be unique for each session to identify the room for the user to join.peer
: the peer id, this is also an unique string for each user to identify themselves in the room.token
: is an access token each peer needs to connect to the room. This token is generated by the server and should be kept secret. You can read more about token here.
Disconnect from a session
You should call session.disconnect()
to disconnect from a session. This will also stop all the tracks and close the connection to the server.