bởi gus

Janode is a Node.js and browser-compatible adapter for the Janus WebRTC server, wrapping the core API, Admin API, and popular plugins via WebSocket or Unix DGRAM Sockets.
Janode is a Node.js and browser-compatible adapter for the Janus WebRTC server. It wraps the Janus core API, Admin API, and plugin APIs (AudioBridge, VideoRoom, EchoTest, Streaming, SIP, Record&Play, TextRoom) behind a clean async/await interface. The typical buyer is a backend engineer building a Node.js signaling server or media orchestration layer on top of a self-hosted Janus instance.
janode.js - Main entry point; exports Janode.connect() and core event constantsconnection.js - Connection class; manages transport lifecycle and session creationsession.js - Session class; manages Janus sessions and handle attachmenthandle.js - Handle base class; extend this for custom plugin handlesprotocol.js - Janus wire-protocol constants and message type guardsconfiguration.js - Internal configuration parser and validatortmanager.js - Transaction manager for correlating async Janus responsestransport-ws.js - WebSocket transport (uses isomorphic-ws / ws)transport-unix.js - Unix DGRAM socket transport (uses unix-dgram)utils/logger.js - Leveled logger exported as Janode.Loggerutils/utils.js - Internal utilities (ID generation, URL checking, iterators)plugins/audiobridge-plugin.js - AudioBridge plugin handleplugins/echotest-plugin.js - EchoTest plugin handleplugins/recordplay-plugin.js - Record&Play plugin handleplugins/sip-plugin.js - SIP plugin handleplugins/streaming-plugin.js - Streaming plugin handleplugins/textroom-plugin.js - TextRoom plugin handleplugins/videoroom-plugin.js - VideoRoom plugin handlenpm install isomorphic-ws ws unix-dgram
Native build note:
unix-dgramrequires native compilation via . You must have Python 3 and a C++ build toolchain installed ( on Debian/Ubuntu, Xcode CLT on macOS). On Linux servers without a desktop environment this is typically already present. If you only use WebSocket transport you can optionally skip but the source will still attempt to import it, so it must be resolvable.
Khởi chạy sandbox cách ly và chạy phía máy chủ — không cần cài đặt cục bộ.
Tetrees AI Review cho phiên bản này
This JavaScript library / package completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Quy trình avcp-2026-08-04.1 · SHA-256 46a52d29ec8315d5…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Đã đánh giá 4 thg 8, 2026
Đưa sản phẩm này thẳng vào AI IDE, trình tạo web hoặc cloud IDE của bạn.
Kết nối Tetrees với AI IDE tương thích để liệt kê sản phẩm bạn sở hữu và nhận ZIP đã xác minh mà không cấp quyền tải lên của người bán.
Chưa có đánh giá.
Sign in to join the discussion
Loading discussion…
node-gypbuild-essentialunix-dgramCopy the source/ directory into your project, e.g. src/janode/.
Ensure your package.json includes "type": "module" or your bundler handles ESM, because all source files use import/export syntax.
If using TypeScript, add a path alias in tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"janode": ["src/janode/janode.js"],
"janode/plugins/*": ["src/janode/plugins/*"]
},
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
Set environment variables consumed by your app (none are required by the library itself — connection credentials are passed programmatically).
If using Babel, ensure @babel/plugin-transform-modules-commonjs or equivalent is configured so ESM imports resolve.
For production deployments that only use WebSockets, you may stub unix-dgram if native compilation is unavailable:
// package.json
"browser": {
"unix-dgram": false
}
import Janode from './janode/janode.js';
function connect(config: {
is_admin: boolean;
address: {
url: string; // ws://, wss://, file:// (unix)
apisecret?: string;
} | Array<{ url: string; apisecret?: string }>;
retry_time_secs?: number;
max_retries?: number;
}): Promise<Connection>
The primary entry point. Call it once at startup to obtain a Connection. Pass is_admin: true to target the Janus Admin API port. Pass multiple entries in address for failover across Janus nodes.
// on a Connection instance returned by Janode.connect()
connection.create(): Promise<Session>
Creates a Janus session over the established connection. One connection can hold multiple sessions. Call this before attaching any plugin handles. The returned Session emits events such as JANODE.EVENT.SESSION_DESTROYED.
// on a Session instance returned by connection.create()
session.attach(pluginDescriptor: {
id: string; // Janus plugin identifier string
Handle: typeof Handle;
}): Promise<Handle>
Attaches to a Janus plugin and returns a typed handle. Pass a plugin module's exported descriptor (e.g. EchoTestPlugin, VideoRoomPlugin). The returned handle exposes plugin-specific methods and emits plugin-specific events. Always await handle.detach() when done.
// extended by every plugin handle
class Handle extends EventEmitter {
id: number;
session: Session;
detach(): Promise<void>;
hangup(): Promise<void>;
// plugin-specific methods defined in each plugin file
}
The base class for all plugin handles. Users extending Janode with custom plugins must subclass Handle and override handleMessage. Subscribe to Janode.EVENT.HANDLE_WEBRTCUP, HANDLE_HANGUP, HANDLE_MEDIA, HANDLE_SLOWLINK, and HANDLE_DETACHED for WebRTC lifecycle events.
Establish a WebSocket connection to Janus, create a session, attach the EchoTest plugin, send an offer, and receive an answer. This is the minimal integration path for testing connectivity.
import Janode from './janode/janode.js';
import EchoTestPlugin from './janode/plugins/echotest-plugin.js';
const { Logger } = Janode;
async function runEchoTest(offerSdp: string) {
const connection = await Janode.connect({
is_admin: false,
address: { url: 'ws://127.0.0.1:8188/', apisecret: 'secret' },
});
const session = await connection.create();
const echoHandle = await session.attach(EchoTestPlugin);
echoHandle.on(Janode.EVENT.HANDLE_WEBRTCUP, () => Logger.info('WebRTC up'));
echoHandle.on(Janode.EVENT.HANDLE_HANGUP, (data: unknown) => Logger.info('hangup', data));
// EchoTestPlugin exposes a start() method
const { jsep: answerSdp } = await (echoHandle as any).start({
video: true,
audio: true,
jsep: { type: 'offer', sdp: offerSdp },
});
Logger.info('Got answer SDP', answerSdp);
await echoHandle.detach();
await session.destroy();
await connection.close();
return answerSdp;
}
Use the Admin API port to inspect Janus server state without creating media sessions. Useful for health checks or monitoring dashboards.
import Janode from './janode/janode.js';
async function listJanusSessions(): Promise<unknown[]> {
const admin = await Janode.connect({
is_admin: true,
address: { url: 'ws://127.0.0.1:7188/', apisecret: 'secret' },
});
const sessions = await (admin as any).listSessions();
console.log('Active sessions:', sessions);
await (admin as any).close();
return sessions;
}
Attach to the VideoRoom plugin to create a room and join as a publisher. Demonstrates plugin-specific methods and event subscriptions.
import Janode from './janode/janode.js';
import VideoRoomPlugin from './janode/plugins/videoroom-plugin.js';
async function publishToVideoRoom(offerSdp: string, roomId: number) {
const connection = await Janode.connect({
is_admin: false,
address: { url: 'ws://127.0.0.1:8188/', apisecret: 'secret' },
});
const session = await connection.create();
const vrHandle = await session.attach(VideoRoomPlugin);
// VideoRoomPlugin exposes join(), publish(), etc.
await (vrHandle as any).joinPublisher({ room: roomId, display: 'Node Publisher' });
vrHandle.on((VideoRoomPlugin as any).EVENT.VIDEOROOM_DESTROYED, () =>
console.log('Room destroyed')
);
const { jsep: answer } = await (vrHandle as any).publish({
jsep: { type: 'offer', sdp: offerSdp },
});
console.log('Publishing, answer SDP:', answer);
return { vrHandle, session, connection };
}
janode.js - Exports the Janode default object with connect(), EVENT constants, and Logger. This is the only file consumers import directly from the core.connection.js - Connection class wrapping a transport instance. Handles session map, transaction correlation, and reconnection logic.session.js - Session class. Owns keepalive timers, handle registry, and routes incoming Janus messages to the correct handle.handle.js - Handle base class that plugin handles inherit. Contains transaction dispatch, message routing, and detach logic.protocol.js - String constants for Janus message types (janus, ack, event, etc.) and type-guard helpers (isAckData, isErrorData, isResponseData).configuration.js - Validates and normalizes the config object passed to connect(). Internal use only.tmanager.js - TransactionManager maps outgoing transaction IDs to pending promise resolvers.transport-ws.js - WebSocket transport with ping/pong keepalives and configurable retry logic.transport-unix.js - Unix DGRAM socket transport; binds a local socket at /tmp/.janode-<id>.utils/logger.js - Simple leveled logger (verbose, info, warn, error) accessible as Janode.Logger.utils/utils.js - getNumericID, checkUrl, newIterator, delayOp — internal helpers.plugins/ - One file per supported Janus plugin. Each exports a plugin descriptor { id, Handle } and plugin-specific EVENT constants.unix-dgram fails to build on CI/Docker — Install build-essential (Linux) or ensure Xcode CLT is present; or set "unix-dgram": false in package.json browser field if you only use WS transport.ERR_REQUIRE_ESM) — The source uses import/export; set "type": "module" in your package.json or use .mjs extensions; do not require() these files."janode/plugins/*": ["src/janode/plugins/*"] to tsconfig.json paths and ensure moduleResolution is NodeNext or Bundler.apisecret mismatch causes all requests to return 403 — The apisecret in your config must exactly match the api_secret value in janus.jcfg.ka_interval) is shorter than Janus's session_timeout; the default is 30 s but Janus default timeout is also 60 s.max_retries and retry_time_secs explicitly in connect() config; the defaults may not match your infrastructure's restart latency.I have dropped the Janode source library into `src/janode/` in my Node.js project.
The upstream npm package is `user@example.com`. The integration guide is in `USAGE.md`.
Please help me integrate it step by step:
1. Read `USAGE.md` and `src/janode/janode.js` to understand the public API.
2. Install all required dependencies listed in `USAGE.md`.
3. Create a `src/janusService.ts` module that:
- Connects to Janus at the URL stored in the `JANUS_URL` env var using `Janode.connect()`.
- Creates a session and exposes `getSession()`.
- Attaches to the VideoRoom plugin (`src/janode/plugins/videoroom-plugin.js`) and exposes `getVideoRoomHandle()`.
- Gracefully closes the connection on process exit.
4. Wire the service into my existing Express app in `src/server.ts`.
5. Add TypeScript types where the library does not provide them (use `any` sparingly).
6. Show me how to subscribe to `Janode.EVENT.HANDLE_WEBRTCUP` and `HANDLE_HANGUP` events.
Only use APIs visible in `USAGE.md` and the source files under `src/janode/`. Do not invent method names.
The upstream library is published under the MIT License by Meetecho s.r.l. See source/LICENSE if present, or refer to the npm package page and the GitHub repository for the full license text. This AVCP block redistributes the source of user@example.com unmodified.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
Hướng dẫn cài đặt đầy đủ và prompt tích hợp sẽ mở khóa sau khi mua.
PHP, Laravel & Business Scripts
Miễn phí