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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@knock-knock/server

v0.0.1

Published

Serverside library for knock-knock

Readme

@knock-knock/server

Ultrasonic proximity detection library for real-time clustering of nearby users.

What it does

This server-side library detects which users are physically close to each other using ultrasonic frequencies (17-20 kHz). It manages WebSocket connections, assigns unique frequencies to users, processes proximity data, and clusters users based on mutual frequency detection.

Key features:

  • Assigns unique ultrasonic frequencies to users within sessions
  • Processes frequency detection data from clients
  • Clusters users based on mutual proximity detection
  • Real-time WebSocket communication and updates
  • Session isolation (different sessions can reuse frequencies)

Use Cases

Meeting & Collaboration

  • Automatically group meeting participants by location
  • Create breakout rooms based on physical proximity
  • Detect when remote participants are actually in the same room

Events & Networking

  • Connect nearby attendees at conferences or events
  • Facilitate spontaneous networking opportunities
  • Group people for activities or discussions

Gaming & Social

  • Proximity-based multiplayer games
  • Social apps that connect people in the same space
  • Location-aware features without GPS

Workplace & Education

  • Team formation based on physical proximity
  • Classroom interaction and group activities
  • Office space utilization and collaboration tracking

How it works

  1. Session Creation: Users join sessions via WebSocket connections
  2. Frequency Assignment: Each user receives a unique ultrasonic frequency (17-20 kHz)
  3. Audio Processing: Client devices emit assigned frequencies and listen for others
  4. Detection Reporting: Clients send frequency detection data to the server
  5. Mutual Verification: Server verifies bidirectional detection between users
  6. Clustering: Graph-based algorithm groups users who mutually detect each other
  7. Real-time Updates: Proximity changes are broadcast to all session participants

Installation

npm install @knock-knock/server

Basic Usage

import { KnockKnockServer } from '@knock-knock/server';

// Initialize server with frequency range (Hz) and spacing
const server = new KnockKnockServer(17800, 19200, 100); // 15 users max

// Handle WebSocket connections
server.handleConnection(websocket, 'user123', 'session-abc');

// Get proximity clusters
const allUsers = server.getUsers('session-abc');          // [['user1'], ['user2', 'user3']]
const nearby = server.getUsersTogetherOnly('session-abc'); // [['user2', 'user3']]

Frontend Integration

Note: A companion frontend library @knock-knock/browser is in development to handle audio processing, microphone/speaker operations, and WebSocket communication. This server library is designed to work with that client library.

Your client needs to:

// Send frequency detections to server
websocket.send(JSON.stringify({
  type: 'frequency_heard',
  data: {
    frequency: 17900,
    amplitude: 0.8,
    confidence: 0.95
  }
}));

// Receive proximity updates
websocket.on('message', (data) => {
  const message = JSON.parse(data);
  if (message.type === 'proximity_update') {
    console.log('Nearby users:', message.data.nearbyUsers);
  }
});

API Reference

KnockKnockServer(frequencyLower, frequencyUpper, spacing)

  • frequencyLower: Minimum frequency (Hz)
  • frequencyUpper: Maximum frequency (Hz)
  • spacing: Frequency spacing between users (Hz)

Methods

  • handleConnection(websocket, userId, sessionId) - Handle new user connection
  • getUsers(sessionId) - Get all user clusters in session
  • getUsersTogetherOnly(sessionId) - Get multi-user clusters only
  • getMaxUsersPerSession() - Calculate max users based on frequency range

Requirements

  • WebSocket server (ws, socket.io, etc.)
  • Client-side audio frequency detection and emission
  • Ultrasonic speaker/microphone capability on client devices

License

MIT