0.5.2 • Published 5 years ago

@superhero/socket v0.5.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Socket

Licence: MIT


npm version

A socket connection for "server to server" communication.

Install

npm install @superhero/socket

...or just set the dependency in your package.json file:

{
  "dependencies":
  {
    "@superhero/socket": "*"
  }
}

Example Application

A simple example to get started follows.

const
SocketFactory = require('@superhero/socket'),
socketFactory = new SocketFactory,
// Debug      = require('@superhero/debug'),
// log        = new Debug({ debug:true }),
log           = console,
server        = socket.createServer(log),
client        = socket.createClient(log),
port          = 18200,
event         = 'foobar',
body          = { foo:'bar' }

server.listen(port)
client.connect(port)

client.emit(event, body)
server.on(event, (context, data) => context.emit(event, body))
client.on(event, (context, data) =>
{
  // if you need to close the connection, then...
  client.client.end()
  server.server.close()
})
0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

6 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.2.0

6 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.2

7 years ago

0.1.3

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago