icet
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i icet

Weekly Downloads

2

Version

0.0.4

License

MIT

Unpacked Size

216 kB

Total Files

54

Last publish

Collaborators

  • shinyoshiaki