1. Include the SDK
For Browsers:
<script src="https://cdn.jsdelivr.net/gh/steveseguin/ninjasdk@latest/vdoninja-sdk.min.js"></script>
For Node.js:
npm install ws @roamhq/wrtc # or node-datachannel
# Then in your code:
const VDONinjaSDK = require('./vdoninja-sdk-node.js');
See README-NODE.md for detailed Node.js setup instructions.
2. Basic Data Channel Example
// Create a new VDO.Ninja SDK instance
const vdo = new VDONinjaSDK();
// Set up data channel handling
vdo.addEventListener('data', (event) => {
const { data, uuid } = event.detail;
console.log(`Received from ${uuid}:`, data);
});
// Connect, join room, and announce
await vdo.connect();
await vdo.joinRoom({ room: "myroom" });
await vdo.announce({ streamID: "ai-bot-1" });
// Send data to all peers
vdo.sendData({
type: "chat",
message: "Hello from AI bot!"
});
3. Audio/Video Example
// Create instance for audio/video
const vdo = new VDONinjaSDK();
// Set up track handling
vdo.addEventListener('track', (event) => {
const { track, streams, uuid } = event.detail;
const video = document.getElementById('remoteVideo');
if (!video.srcObject) {
video.srcObject = new MediaStream();
}
video.srcObject.addTrack(track);
});
// Get user media
const stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
});
// Connect, join room, and publish
await vdo.connect();
await vdo.joinRoom({ room: "videoroom" });
await vdo.publish(stream, { room: "videoroom" });
💬 Social Stream Ninja Integration
Two-way live chat with all major social media platforms in one unified stream
🌐 Supported Platforms
🚀 Simple Integration
📊 Use Cases