{"library":"protoo-client","title":"protoo-client","description":"protoo-client is the client-side JavaScript library for the protoo signaling framework, designed for building multi-party Real-Time Communication (RTC) applications. It supports both browser and Node.js environments, requiring a compatible WebSocket implementation (native `WebSocket` in browsers, or a library like `ws` in Node.js). The current stable version is 4.0.8, and the project appears to follow semantic versioning with notable breaking changes between major releases, indicating active development. It differentiates itself by offering a minimalist and extensible approach to signaling, focusing specifically on WebRTC use cases.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install protoo-client"],"cli":null},"imports":["import { Peer } from 'protoo-client';","const { Peer } = require('protoo-client');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Peer } from 'protoo-client';\nimport { WebSocket } from 'ws'; // Only for Node.js. In browsers, use native WebSocket.\n\nconst WEBSOCKET_URL = process.env.PROTOO_SERVER_URL || 'wss://your.protoo.server:4443';\n\nasync function connectProtoo() {\n  let ws;\n  if (typeof window === 'undefined') {\n    // Node.js environment\n    ws = new WebSocket(WEBSOCKET_URL);\n  } else {\n    // Browser environment\n    ws = new WebSocket(WEBSOCKET_URL);\n  }\n\n  const peer = new Peer(ws);\n\n  peer.on('open', () => {\n    console.log('Protoo Peer connected to server!');\n    // Example: Send an initial request\n    peer.request('hello', { message: 'Hello from client!' })\n      .then(response => console.log('Server response:', response))\n      .catch(error => console.error('Request failed:', error));\n  });\n\n  peer.on('close', () => {\n    console.log('Protoo Peer disconnected.');\n  });\n\n  peer.on('error', (error) => {\n    console.error('Protoo Peer error:', error.message);\n  });\n\n  peer.on('request', async (request, accept, reject) => {\n    console.log('Received request from server:', request.method, request.data);\n    try {\n      if (request.method === 'ping') {\n        accept({ pong: 'received' });\n      } else {\n        reject(new Error('Unknown request method'));\n      }\n    } catch (error) {\n      reject(error);\n    }\n  });\n\n  peer.on('notification', (notification) => {\n    console.log('Received notification from server:', notification.method, notification.data);\n  });\n}\n\nconnectProtoo();","lang":"typescript","description":"This quickstart demonstrates how to instantiate a protoo-client Peer, establish a WebSocket connection, and handle basic 'open', 'close', 'error', 'request', and 'notification' events. It distinguishes between Node.js and browser WebSocket usage.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}