Comparing version 1.0.1 to 1.0.2
@@ -14,4 +14,5 @@ (function( $ ) { | ||
$this.socket = io.connect(url); | ||
$this.socket = io.connect(url, {secure: true}); | ||
$this._trigger = $this.trigger; | ||
$this.events = {}; | ||
@@ -29,4 +30,22 @@ $this.socket.on('connect', function() { | ||
/* | ||
* An optional helper function to set up compiler-checkable event names | ||
* var clickEvent = hub.addEvent('click'); | ||
* clickEvent.bind(function(...) { ... } ); | ||
* clickEvent.trigger({ foo: 'goo' }, ... ); | ||
*/ | ||
$this.addEvent = function(eventName) { | ||
var _this = this; | ||
this.events[eventName] = { | ||
bind: function(callback) { _this.bind.call(_this, eventName, callback); } | ||
, trigger: function() { | ||
Array.prototype.unshift.call(arguments, eventName); | ||
_this.trigger.apply(_this, arguments); | ||
} | ||
}; | ||
return this.events[eventName]; | ||
}; | ||
return $this; | ||
}; | ||
})(jQuery); |
YUI().add('EventHub', function(Y) { | ||
Y.EventHub = function(io, url) { | ||
var _this = this; | ||
this.events = {}; | ||
this._fire = this.fire; | ||
@@ -13,2 +14,20 @@ this.socket = io.connect(url); | ||
}; | ||
/* | ||
* An optional helper function to set up compiler-checkable event names | ||
* var clickEvent = hub.addEvent('click'); | ||
* clickEvent.on(function(...) { ... } ); | ||
* clickEvent.fire({ foo: 'goo' }, ... ); | ||
*/ | ||
this.addEvent = function(eventName) { | ||
var _this = this; | ||
this.events[eventName] = { | ||
on: function(callback) { _this.on.call(_this, eventName, callback); } | ||
, fire: function() { | ||
Array.prototype.unshift.call(arguments, eventName); | ||
_this.fire.apply(_this, arguments); | ||
} | ||
}; | ||
return this.events[eventName]; | ||
}; | ||
}; | ||
@@ -15,0 +34,0 @@ Y.augment(Y.EventHub, Y.EventTarget); |
var connect = require('connect') | ||
, server = connect.createServer( | ||
connect.logger() | ||
, connect.static(__dirname + '/../..') | ||
, connect.static(__dirname + '/../../..') | ||
, connect.static(__dirname) | ||
@@ -6,0 +6,0 @@ ) |
@@ -1,8 +0,8 @@ | ||
var eventHub = require('../../clients/server/eventClient.js').getClientHub('http://localhost:8888'); | ||
var eventHub = require('../../clients/server/eventClient.js').getClientHub('http://localhost:5883'); | ||
eventHub.on('eventHubReady', function() { console.log("EventHub ready!"); }); | ||
eventHub.on('click', function(data, callback) { | ||
console.log('GOT A CLICK Event'); | ||
console.log(data); | ||
callback('howdy from server', { mark: 'trostler' }); | ||
console.log('GOT A CLICK Event'); | ||
console.log(data); | ||
callback('howdy from server', { mark: 'trostler' }); | ||
}); |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Mark Ethan Trostler <mark@zzo.com>", | ||
@@ -16,0 +16,0 @@ "preferGlobal": true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17178
213