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

eventsocket

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventsocket

Event socket

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

eventsocket

Event socket

Install

$ npm install eventsocket

Usage

var EventSocket = require('eventsocket');

Methods

EventSocket(options)

EventSocket(port, [host])

EventSocket(path)

Create new event socket. Same as net.connect.

var socket = new EventSocket(7000, '127.0.0.1');

EventSocket(socket)

Create new event socket from existingnet.Socket or JsonSocket

var net = require('net');
var server = net.createServer(function (con) {
    var socket = new EventSocket(con);
}

emit(eventType, args...)

Send event over socket.

socket.emit('message',{foo: 'bar'});

disconnect()

Destroy connection

connect(port, [host])

connect(path)

Same as net.Socket.connect

on(eventType, listener)

Inherited from events.EventEmitter

Events

connect

Emitted when socket connected (only when you pass ip, port).

disconnect

Emitted when disconnected.

Custom

Emitted event from peer

error

Emitted when net.Socket emit error.

Error events are treated as a special case in node. If there is no listener for it, then the default action is to print a stack trace and exit the program.

see more.

newListener, removeListener

Inherited from EventEmitter.

Logging

You can enable logging. See more

# disabled logging
node test.js

# connect, disconnect log
DEBUG=EventSocket:connection node test.js

# data log
DEBUG=EventSocket:data node test.js

# all event socket logs
DEBUG=EventSocket:* node test.js

Protocol

We send json objects over socket then write one \0. This is c/c++ friendly protocol. :smile:

Json object has name and args property. name must be string and args must be array.

{"name":"message","args":[{"foo":"bar"}]}\0

Keywords

FAQs

Package last updated on 06 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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