Skip to content

Latest commit

 

History

History
76 lines (59 loc) · 1.23 KB

README.md

File metadata and controls

76 lines (59 loc) · 1.23 KB

Enyo-Socket.io

Socket.io wrapper for EnyoJS

Example

Can be used in much the same way as Socket.io

var socket = new Socket();
socket.on('example', function(data){
  console.log(data);
});

Can also be passed a map of key-value pairs for on()

var socket = new Socket();
socket.on({
  example: function(data){
    console.log(data);
  },
  example2: function(data){
    console.log(data);
  }
});

Constructor can take an initial map of key-value pairs that will be passed to on() during instantiation

var socket = new Socket({
  init: {
    on: {
      example: function(data){
        console.log(data);
      },
      example2: function(data){
        console.log(data);
      }
    }
  }
});

Convenience function for emit exists on Socket

var socket = new Socket();
socket.emit('example', 'example data');

Socket.io address can be configured on instantiation (Defaults to window.location.host)

var socket = new Socket({
  address: 127.0.0.1
});

Socket.io configuration options can be passed to constructor as connOptions

var socket = new Socket({
  connOptions: {
    transports: ['websocket']
  }
});

TODO

Enyo Tests

Solidify API