npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

callfusion-server

v2.0.0

Published

A WebRTC signaling and peer connection server library

Downloads

11

Readme

CallFusion

CallFusion is a JavaScript class for managing real-time client connections and handling communication events such as calls, messages, and client disconnections using Socket.IO.

Features

  • Client Management: Register, deregister, and track clients using accountId, socketId, and custom names.
  • Real-time Messaging: Handle messages between clients, including notifications for calls, call acceptance, and denial.
  • Custom Handlers: Define custom handlers for broadcasting client lists, notifying calls, and relaying messages.

Prerequisites

  • Node.js: Ensure you have Node.js installed. Download Node.js
  • Socket.IO: For real-time communication.

Installation

  1. Clone the repository or integrate the CallFusion class into your project.

  2. Install dependencies:

    npm install socket.io

    Note: Mongoose is not a dependency of CallFusion. It's only used as part of an example setup. If you're using MongoDB for user management, you'll need to install it separately:

    npm install mongoose

Usage

Step 1: Set Up Mongoose (Optional)

If you are using MongoDB to store user/client information, define your Mongoose model for storing user/client information. This could include fields like accountId, name, email, and socketId.

// userModel.js

const mongoose = require("mongoose");

const userSchema = new mongoose.Schema({
	accountId: { type: String, required: true, unique: true },
	name: { type: String, required: true },
	email: { type: String, required: true, unique: true },
	socketId: { type: String }, // Optional, for storing socket information
});

const User = mongoose.model("User", userSchema);

module.exports = User;

Step 2: Set Up Socket.IO with CallFusion

Here’s an example of how to use the CallFusion class with Socket.IO. This setup also includes an optional example using Mongoose for MongoDB, but Mongoose is not a required dependency of CallFusion.

const http = require("http");
const socketIo = require("socket.io");
const { CallFusion } = require("./callFusion"); // Import the CallFusion class
const User = require("./userModel"); // Example: Import the Mongoose user model (optional)

// Create HTTP server and initialize Socket.IO
const server = http.createServer();
const io = socketIo(server);

// Initialize CallFusion instance
const callFusion = new CallFusion();

// Example: Connect to MongoDB (optional)
mongoose.connect("mongodb://localhost:27017/your-database", {
	useNewUrlParser: true,
	useUnifiedTopology: true,
	useCreateIndex: true,
});

// Handle client connections via Socket.IO
const cf = new CallFusion(io);

io.on("connection", (socket) => {
	let clientId = uuidv4();
	cf.registerClient(socket, {
		clientId: clientId,
		name: "User-" + clientId,
	});
});

// Start the server
const port = 5200;
server.listen(port, () => {
	console.log(`Server is running on port ${port}`);
});

License

This project is licensed under the MIT License.