socket-utils

0.1.0 • Public • Published

gaw-socket-utils

build status

very simple utilities to get information from a socket.io (v1.0.0+) connection

Install

$ npm install --save socket-utils

Tests

$ npm test

Coverage

$ npm run cover

API

utils.socketInfo()

Params
Name Type Description
socket socket.io.Socket A connected socket object
Example
io.on('connection', function(socket) {
  socket.on('info', function() {
    var info = utils.socketInfo(this)
    console.log(info)
    // => {
    // =>   user: { id: 1, name: 'Evan' },
    // =>   address: '127.0.0.1',
    // =>   headers: {
    // =>     connection: 'keep-alive',
    // =>     'user-agent': 'blah blah'
    // =>   }
    // => }
  })
})

Readme

Keywords

Package Sidebar

Install

npm i socket-utils

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • eh
  • evanlucas