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

mse-proto-server

v0.2.0

Published

Media server engine protocol for client/server communication based on JSON RPC 2.0.

Downloads

4

Readme

MSE protocol

version: 1.0

This protocol is used by media server engine (MSE) and clients for communication. Protocol is based on JSON RPC 2.0.

Example usage

  • Install package using NPM:
npm i --save mse-proto
const WebSocket = require('ws')
const proto = require('mse-proto')
const RequestFactory = proto.RequestFactory
const ResponseAdapter = proto.ResponseAdapter

const wss = new WebSocket(`wss://mse:443/`)

wss.on('open', (ws) => {
  wss.send(RequestFactory.ping())
})
wss.on('message', (response) => {
  if (ResponseAdaptor.ping(response)) {
    console.log(response)
  }
})

Messages

Errors


ping

  • ping server. Method can be used as heartbeat.

ping request (client)

{
  "id": 1,
  "method": "ping",
  "jsonrpc": "2.0"
}

ping success response (server)

{
  "id": 1,
  "result": "pong",
  "jsonrpc": "2.0"
}

authentication

authentication request (client)

  • A JWT token is used for authentication. Subsequent calls do NOT need the token.
{
  "id": 2,
  "method": "auth",
  "jsonrpc": "2.0",
  "params": {
    "token": "appropriate jwt token",
    "version": "1.0"
  }
}

authentication success response (server)

{
  "id": 2,
  "jsonrpc": "2.0",
  "result": "authenticated"
}

start

start request (client)

  • This method is available only to authorized clients.
  • Starts video service.
{
  "id": 3,
  "method": "start",
  "jsonrpc": "2.0"
}

start success response (server)

{
  "id": 3,
  "jsonrpc": "2.0",
  "result": "started"
}

whoami

whoami request (client)

  • Available in development environment only.
  • This method is available only to authorized clients.
{
  "id": 4,
  "method": "whoami",
  "jsonrpc": "2.0"
}

whoami success response (server)

{
  "id": 4,
  "jsonrpc": "2.0",
  "result": {
    "domain": "domain",
    "agent": "web or mobile",
    "role": "user - admin or super",
    "userId": "random string",
    "roomId": "random string",
    "ipAddress": "client ip address",
    "tokenIssued": "date the token is issued",
    "validFrom": "token is valid from date",
    "validTo": "token is valid to date"
  }
}

iceCandidate

iceCandidate request (client & server)

  • This method is available only to authorized clients.
  • This method is a notification. Server does NOT respond to it and client should not too.
{
  "id": null,
  "method": "iceCandidate",
  "jsonrpc": "2.0",
  "params": {
    "candidate": "ice candidate value"
  }
}

sdpOffer

sdpOffer request (client & server)

  • This method is available only to authorized clients.
  • This method is a notification. Server does NOT respond to it and client should not too.
{
  "id": null,
  "method": "sdpOffer",
  "jsonrpc": "2.0",
  "params": {
    "offer": "sdp offer value"
  }
}

disconnect

disconnect request (client)

  • This method is available only to authorized clients.
  • This method is a notification. Server does NOT respond to it.
{
  "id": null,
  "method": "disconnect",
  "jsonrpc": "2.0"
}

Chat message (client & server)

  • NOT IMPLEMENTED
  • This method is available only to authorized clients.
  • This method is a notification. Server does NOT respond to it and client should not too.
{
  "id": null,
  "method": "chat",
  "jsonrpc": "2.0",
  "params": {
    "to": [],
    "message": "message",
    "attachment": "object"
  }
}

Errors

Invalid json object

{
  "id": null
  "jsonrpc": "2.0",
  "error": {
    "code": -32700,
    "message": "Parse error"
  }
}

Invalid json rpc 2.0 object

{
  "id": null
  "jsonrpc": "2.0",
  "error": {
    "code": -1001,
    "message": "Invalid json rpc 2.0 object"
  }
}

Method not found

{
  "id": "related request id",
  "jsonrpc": "2.0",
  "error": {
    "code": -32601,
    "message": "Method not found"
  }
}

Invalid method parameter

{
  "id": "related request id",
  "jsonrpc": "2.0",
  "error": {
    "code": -32602,
    "message": "Invalid params"
  }
}

Authentication failure

{
  "id": "related request id",
  "jsonrpc": "2.0",
  "error": {
    "code": -4001,
    "message": "Authorization Failed"
  }
}

Unauthorized access

{
  "id": "related request id",
  "jsonrpc": "2.0",
  "error": {
    "code": -5001,
    "message": "Unauthorized Access"
  }
}

Invalid call order

  • Calling a method before calling required methods before it.
{
  "id": 3,
  "jsonrpc": "2.0",
  "error": {
    "code": -6001,
    "message": "Invalid Call Order",
    "data": {
      "required": "Required Method"
    }
  }
}