Socket
Socket
Sign inDemoInstall

co.stream

Package Overview
Dependencies
49
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    co.stream

compoundjs+socketio and streaming uploads via Route#map method


Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Socket.IO bindings for CompoundJS

Installation

npm install co-socket --save

then add co-socket to config/autoload.js

Usage

Add routes to config/routes.js

map.socket('some-event', 'controller#action');

When client emit event some-event, then action action of controller controller will gain control. Data passed to the event will be available as params variable. Calling send will call the callback to the current socket.

Available methods in any controller

action('some-action', function () {
    socket().emit('event', {some: 'data'}); // send 'event' to all clients in current session
    socket(anotherSessionID).emit('hello'); // send 'hello' to another user
                                            // identifyed by anotherSessionID

    var clients = socketClients();          // list of current session clients
    clients.forEach(function (client) {
        client.join('room');                // current session clients join a room
    });

    // List of clients in another session
    var anotherSessionClients = socketClients(anotherSessionID);
});

Any controller action (both socket and non-socket) can emit some event with any client.

Responding to the current request

Server side:

app/controllers/some-controller.js

action('join', function () {
    send({ foo: 'bar' });
});
Client side:
socket.emit('join', {}, function (data) {
    console.log(data.foo); // bar
});

Inner structure

All socket.io connections automatically join a room named after the compound sessionID. If you want to communicate with another user you can specify their sessionID as param for both socket or socketClients method.

License

MIT

Keywords

FAQs

Last updated on 19 Nov 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc