Permalink
Browse files

Made JS hubConnection API consistent with .NET but in JS style.

Updated MouseTracking sample to use new hubConnection API.
  • Loading branch information...
1 parent 7089b32 commit 93c2dd2a624bb1d4271f35624d7eacd7a1a2ab5f @DamianEdwards DamianEdwards committed Aug 22, 2012
@@ -104,22 +104,38 @@
// hubConnection
- function hubConnection(url) {
+ function hubConnection(url, options) {
/// <summary>Creates a new hub connection.</summary>
- /// <param name="url" type="String">[Optional] The hub route url, defaults to "/signalr"</param>
- if (!url) {
- url = "/signalr";
+ /// <param name="url" type="String">[Optional] The hub route url, defaults to "/signalr".</param>
+ /// <param name="options" type="Object">[Optional] Settings to use when creating the hubConnection.</param>
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath : true
+ };
+
+ $.extend(settings, options);
+
+ if (!url || settings.useDefaultPath) {
+ url = (url || "") + "/signalr";
}
- return new hubConnection.fn.init(url);
+ return new hubConnection.fn.init(url, settings);
}
hubConnection.fn = hubConnection.prototype = $.connection();
- hubConnection.fn.init = function (url, qs, logging) {
- var connection = this;
+ hubConnection.fn.init = function (url, options) {
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ },
+ connection = this;
+
+ $.extend(settings, options);
// Call the base constructor
- $.signalR.fn.init.call(connection, url, qs, logging);
+ $.signalR.fn.init.call(connection, url, settings.qs, settings.logging);
// Object to store hub proxies for this connection
connection.proxies = {};
@@ -2,7 +2,7 @@
/// <reference path="../../Scripts/jquery.signalR.js" />
$(function () {
- var hubConnection = $.hubConnection(),
+ var hubConnection = $.hubConnection('/signalr', { qs : 'test=1', logging: false, useDefaultPath: false }),
hub = hubConnection.createProxy('mouseTracking');
hub.on('MoveMouse', function (id, x, y) {
@@ -1407,22 +1407,38 @@
// hubConnection
- function hubConnection(url) {
+ function hubConnection(url, options) {
/// <summary>Creates a new hub connection.</summary>
- /// <param name="url" type="String">[Optional] The hub route url, defaults to "/signalr"</param>
- if (!url) {
- url = "/signalr";
+ /// <param name="url" type="String">[Optional] The hub route url, defaults to "/signalr".</param>
+ /// <param name="options" type="Object">[Optional] Settings to use when creating the hubConnection.</param>
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath : true
+ };
+
+ $.extend(settings, options);
+
+ if (!url || settings.useDefaultPath) {
+ url = (url || "") + "/signalr";
}
- return new hubConnection.fn.init(url);
+ return new hubConnection.fn.init(url, settings);
}
hubConnection.fn = hubConnection.prototype = $.connection();
- hubConnection.fn.init = function (url, qs, logging) {
- var connection = this;
+ hubConnection.fn.init = function (url, options) {
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ },
+ connection = this;
+
+ $.extend(settings, options);
// Call the base constructor
- $.signalR.fn.init.call(connection, url, qs, logging);
+ $.signalR.fn.init.call(connection, url, settings.qs, settings.logging);
// Object to store hub proxies for this connection
connection.proxies = {};
Oops, something went wrong.

0 comments on commit 93c2dd2

Please sign in to comment.