icet
v0.0.4
Published
ICE (RFC 5245) implementation for TypeScript
Downloads
3
Readme
icet
ICE (RFC 5245) implementation for TypeScript
What is icet
?
icet
is a library for Interactive Connectivity Establishment (RFC 5245) in TypeScript .
Implemented with reference to aioice source code
Example
test("example", async () => {
const a = new Connection(true, {
stunServer: ["stun.l.google.com", 19302]
});
const b = new Connection(false, {
stunServer: ["stun.l.google.com", 19302]
});
// # invite
await a.gatherCandidates();
b.remoteCandidates = a.localCandidates;
b.remoteUsername = a.localUserName;
b.remotePassword = a.localPassword;
// # accept
await b.gatherCandidates();
a.remoteCandidates = b.localCandidates;
a.remoteUsername = b.localUserName;
a.remotePassword = b.localPassword;
// # connect
await Promise.all([a.connect(), b.connect()]);
// # send data a -> b
await a.send(Buffer.from("howdee"));
let data = (await b.recv()).toString();
expect(data).toBe("howdee");
// # send data b -> a
await b.send(Buffer.from("gotcha"));
data = (await a.recv()).toString();
expect(data).toBe("gotcha");
await a.close();
await b.close();
});
and see examples/cli