JSPM

werift-sctp

0.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3204
  • Score
    100M100P100Q129523F
  • License MIT

SCTP protocol implementation for Node.js written in TypeScript.

Package Exports

  • werift-sctp
  • werift-sctp/lib/sctp/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (werift-sctp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

werift-sctp

SCTP Implementation for TypeScript
based on aiortc/sctp

Example

import { createSocket } from "dgram";
import { SCTP, WEBRTC_PPID, createUdpTransport } from "werift-sctp";

const port = 5555;

const socket = createSocket("udp4");
socket.bind(port);

const server = SCTP.server(createUdpTransport(socket));
server.onReceive = (_, __, data) => {
  console.log(data.toString());
  server.send(0, WEBRTC_PPID.STRING, Buffer.from("pong"));
};

const client = SCTP.client(
  createUdpTransport(createSocket("udp4"), {
    port,
    address: "127.0.0.1",
  })
);
client.onReceive = (_, __, data) => {
  console.log(data.toString());
};

await Promise.all([client.start(5000), server.start(5000)]);
await Promise.all([
  client.stateChanged.connected.asPromise(),
  server.stateChanged.connected.asPromise(),
]);

client.send(0, WEBRTC_PPID.STRING, Buffer.from("ping"));

reference