Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zyno-bot-addons

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zyno-bot-addons - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

package.json
{
"name": "zyno-bot-addons",
"version": "1.1.1",
"version": "1.1.2",
"description": "Create easily addons for Zyno Bot",

@@ -5,0 +5,0 @@ "main": "index.js",

const EventEmitter = require('events');
const http = require('http');
const WebSocket = require('./websocket.js');
const RequestInfo = require('./requestInfo.js');
const { WebSocketServer } = require('ws');
const { ValueSaver } = require('valuesaver');
const websockets = new ValueSaver();
class WebSocketHandler extends EventEmitter{
constructor(httpServer = http.Server.prototype){
class WebSocket extends EventEmitter{
constructor(socket, handler){
super();
const wsServer = new WebSocketServer({
server: httpServer
let id = Math.round(new Date().getTime() / 1000).toString() + Math.round(Math.random() * 9999).toString();
while(handler.sockets.filter(ws => ws.id === id).length > 0){
id = Math.round(new Date().getTime() / 1000).toString() + Math.round(Math.random() * 9999).toString();
}
this.id = id;
this.send = function(data){
socket.send(data);
};
this.close = () => {
socket.close();
this.emit('close');
this.removeAllListeners();
};
socket.on('message', msg => {
this.emit('message', Buffer.from(msg).toString());
});
wsServer.on('connection', (_ws, req) => {
const reqInfo = new RequestInfo(req, null);
const ws = new WebSocket(_ws, this);
websockets.set(ws.id, _ws);
this.sockets.push(ws);
this.emit('connection', ws, reqInfo);
socket.on('close', () => {
this.emit('close');
this.removeAllListeners();
});
socket.on('error', err => {
var errorMessage = err.message.toString();
handler.errorMessages.push(errorMessage);
})
}
sockets = [];
errorMessages = [];
}
module.exports = WebSocketHandler;
module.exports = WebSocket;
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