New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonrpc2-ws

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonrpc2-ws - npm Package Compare versions

Comparing version 1.0.0-beta13 to 1.0.0-beta14

4

lib/server.d.ts

@@ -94,5 +94,3 @@ /// <reference types="node" />

export declare class Socket extends EventEmitter implements ISocket {
server: Server;
ws: WebSocket;
req: http.IncomingMessage;
readonly id: string;

@@ -102,3 +100,3 @@ readonly rooms: Set<string>;

readonly data: MapLike<any>;
constructor(server: Server, ws: WebSocket, req: http.IncomingMessage);
constructor(ws: WebSocket);
/**

@@ -105,0 +103,0 @@ * Sends a notification to the socket.

@@ -44,2 +44,3 @@ "use strict";

open(callback) {
const self = this;
if (this.wss) {

@@ -54,8 +55,10 @@ throw new Error("`ws` has already been created");

}
this.wss.once("listening", () => this.emit("listening"));
this.wss.on("connection", (ws, req) => {
let socket = new Socket(this, ws, req);
this.sockets.set(socket.id, socket);
ws.once("close", () => {
this.sockets.delete(socket.id);
this.wss.once("listening", function _onListeningWSS() {
self.emit("listening");
});
this.wss.on("connection", function _onConnectionWSS(ws, req) {
let socket = new Socket(ws);
self.sockets.set(socket.id, socket);
ws.once("close", function _onCloseWS() {
self.sockets.delete(socket.id);
socket.emit("close");

@@ -70,6 +73,13 @@ socket.removeAllListeners();

});
ws.on("message", data => this._messageHandler.handleMessage(socket, data).catch(e => this.emit("error", e)));
this.emit("connection", socket, req);
ws.on("message", function _onMessageWS(data) {
self._messageHandler.handleMessage(socket, data)
.catch(function _onErrorHandleMessage(e) {
self.emit("error", e);
});
});
self.emit("connection", socket, req);
});
this.wss.on("error", e => this.emit("error", e));
this.wss.on("error", function _onErrorWSS(e) {
self.emit("error", e);
});
return this;

@@ -167,7 +177,5 @@ }

class Socket extends EventEmitter {
constructor(server, ws, req) {
constructor(ws) {
super();
this.server = server;
this.ws = ws;
this.req = req;
this.id = uuidv4();

@@ -174,0 +182,0 @@ this.rooms = new Set();

{
"name": "jsonrpc2-ws",
"version": "1.0.0-beta13",
"version": "1.0.0-beta14",
"description": "Yet Another Server Library which Implementation of JSON-RPC 2.0 over WebSocket for Node.js (w/ TypeScript)",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc