0.2.11 • Published 4 days ago

@rtco/client v0.2.11

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

@rtco/client

Artico client library. Please refer to the documentation for more information.

Installation

npm install @rtco/client

Usage

The following example shows how to connect two peers and share audio/video or any data between them:

Peer 1

import { Artico, type Call } from "@rtco/client";

const rtco = new Artico();

rtco.on("open", (id: string) => {
  // We're now connected to the signaling server.
  // `id` refers to the unique ID that is currently assigned to this peer, so remote peers can connect to us.
  console.log("Connected to signaling server with peer ID:", id);
});

rtco.on("close", () => {
  console.log("Connection to signaling server is now closed.");
});

rtco.on("error", (err) => {
  console.log("Artico error:", err);
});

rtco.on("call", (call: Call) => {
  // The calling peer can link any metadata object to a call.
  const { metadata } = call;
  const remotePeerName = metadata.name;

  console.log(`Call from ${remotePeerName}...`);

  // Answer the call.
  call.answer();

  call.on("stream", (stream, metadata) => {
    // Stream was added by remote peer, so display it somehow.
    // `metadata` can be appended by the remote peer when adding the stream.
  });
});

Peer 2

import { Artico, type Call } from "@rtco/client";

const remotePeerId = "<ID of target remote peer>";

const rtco = new Artico();

const call = rtco.call(remotePeerId);

call.on("error", (err) => {
  console.log("Call error:", err);
});

call.on("close", () => {
  console.log("Call closed");
});

// ...

navigator.mediaDevices
  .getUserMedia({
    video: true,
    audio: true,
  })
  .then((stream) => {
    // send stream to Peer 1 with metadata indicating type of stream
    call.addStream(stream, {
      type: "camera",
    });
  })
  .catch(console.error);
0.2.11

4 days ago

0.2.10

1 month ago

0.2.9

1 month ago

0.2.7

2 months ago

0.2.6

2 months ago

0.2.8

2 months ago

0.2.5

2 months ago

0.2.1

2 months ago

0.2.0

2 months ago

0.2.3

2 months ago

0.2.2

2 months ago

0.2.4

2 months ago

0.1.30

2 months ago

0.1.31

2 months ago

0.1.32

2 months ago

0.1.28

3 months ago

0.1.29

3 months ago

0.1.27

3 months ago

0.1.20

3 months ago

0.1.21

3 months ago

0.1.22

3 months ago

0.1.23

3 months ago

0.1.24

3 months ago

0.1.25

3 months ago

0.1.26

3 months ago

0.1.19

3 months ago

0.1.17

3 months ago

0.1.18

3 months ago

0.1.16

3 months ago

0.1.15

3 months ago

0.1.10

11 months ago

0.1.11

11 months ago

0.1.12

11 months ago

0.1.13

11 months ago

0.1.14

10 months ago

0.1.8

11 months ago

0.1.7

11 months ago

0.1.9

11 months ago

0.1.6

11 months ago

0.1.5

11 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago