Skip to content

Commit

Permalink
Built
Browse files Browse the repository at this point in the history
  • Loading branch information
NTaylorMullen committed Sep 7, 2012
1 parent 42d527a commit 7f1bfb2
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 33 deletions.
43 changes: 33 additions & 10 deletions samples/SignalR.Hosting.AspNet.Samples/Scripts/jquery.signalR.js
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@
this.state = {};
this.connection = connection;
this.hubName = hubName;
this.subscribed = false;
this.subscribed = [];
},

on: function (eventName, callback) {
Expand All @@ -1361,7 +1361,30 @@
$(self).bind(eventNamespace + eventName, function (e, data) {
callback.apply(self, data);
});
self.subscribed = true;

self.subscribed.push(eventName);

return self;
},

off: function (eventName) {
/// <summary>Removes the callback invocation request from the server hub for the given event name.</summary>
/// <param name="eventName" type="String">The name of the hub event to unregister the callback for.</param>
var self = this;

// Normalize the event name to lowercase
eventName = eventName.toLowerCase();

// Find the location of the event within our subscribed list
var eventLocation = self.subscribed.indexOf(eventName);

// We only want to unbind/remove from our subscribed list if it's an event that we've bound
if (eventLocation >= 0) {
$(self).unbind(eventNamespace + eventName);

// Remove the event from the subscribed list
self.subscribed.splice(self.subscribed.indexOf(eventName), 1);
}
return self;
},

Expand Down Expand Up @@ -1414,7 +1437,7 @@
var settings = {
qs: null,
logging: false,
useDefaultPath : true
useDefaultPath: true
};

$.extend(settings, options);
Expand All @@ -1429,10 +1452,10 @@

hubConnection.fn.init = function (url, options) {
var settings = {
qs: null,
logging: false,
useDefaultPath: true
},
qs: null,
logging: false,
useDefaultPath: true
},
connection = this;

$.extend(settings, options);
Expand All @@ -1450,7 +1473,7 @@
var subscribedHubs = [];

$.each(this.proxies, function (key) {
if (this.subscribed) {
if (this.subscribed.length > 0) {
subscribedHubs.push({ name: key });
}
});
Expand Down Expand Up @@ -1484,7 +1507,7 @@
// Normalize the names to lowercase
hubName = data.Hub.toLowerCase();
eventName = data.Method.toLowerCase();

// Trigger the local invocation event
proxy = this.proxies[hubName];

Expand Down Expand Up @@ -1519,4 +1542,4 @@

$.hubConnection = hubConnection;

} (window.jQuery, window));
}(window.jQuery, window));

Large diffs are not rendered by default.

43 changes: 33 additions & 10 deletions samples/SignalR.Hosting.AspNet45.Samples/Scripts/jquery.signalR.js
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@
this.state = {};
this.connection = connection;
this.hubName = hubName;
this.subscribed = false;
this.subscribed = [];
},

on: function (eventName, callback) {
Expand All @@ -1361,7 +1361,30 @@
$(self).bind(eventNamespace + eventName, function (e, data) {
callback.apply(self, data);
});
self.subscribed = true;

self.subscribed.push(eventName);

return self;
},

off: function (eventName) {
/// <summary>Removes the callback invocation request from the server hub for the given event name.</summary>
/// <param name="eventName" type="String">The name of the hub event to unregister the callback for.</param>
var self = this;

// Normalize the event name to lowercase
eventName = eventName.toLowerCase();

// Find the location of the event within our subscribed list
var eventLocation = self.subscribed.indexOf(eventName);

// We only want to unbind/remove from our subscribed list if it's an event that we've bound
if (eventLocation >= 0) {
$(self).unbind(eventNamespace + eventName);

// Remove the event from the subscribed list
self.subscribed.splice(self.subscribed.indexOf(eventName), 1);
}
return self;
},

Expand Down Expand Up @@ -1414,7 +1437,7 @@
var settings = {
qs: null,
logging: false,
useDefaultPath : true
useDefaultPath: true
};

$.extend(settings, options);
Expand All @@ -1429,10 +1452,10 @@

hubConnection.fn.init = function (url, options) {
var settings = {
qs: null,
logging: false,
useDefaultPath: true
},
qs: null,
logging: false,
useDefaultPath: true
},
connection = this;

$.extend(settings, options);
Expand All @@ -1450,7 +1473,7 @@
var subscribedHubs = [];

$.each(this.proxies, function (key) {
if (this.subscribed) {
if (this.subscribed.length > 0) {
subscribedHubs.push({ name: key });
}
});
Expand Down Expand Up @@ -1484,7 +1507,7 @@
// Normalize the names to lowercase
hubName = data.Hub.toLowerCase();
eventName = data.Method.toLowerCase();

// Trigger the local invocation event
proxy = this.proxies[hubName];

Expand Down Expand Up @@ -1519,4 +1542,4 @@

$.hubConnection = hubConnection;

} (window.jQuery, window));
}(window.jQuery, window));
Loading

0 comments on commit 7f1bfb2

Please sign in to comment.