Skip to content

Commit 7dd6450

Browse files
committed
Updated to official signalr 0.4
1 parent fc4c100 commit 7dd6450

File tree

9 files changed

+48
-41
lines changed

9 files changed

+48
-41
lines changed

JabbR.Test/JabbR.Test.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,15 @@
3434
<WarningLevel>4</WarningLevel>
3535
</PropertyGroup>
3636
<ItemGroup>
37-
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
38-
<Private>True</Private>
39-
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
40-
</Reference>
4137
<Reference Include="Moq">
4238
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
4339
</Reference>
4440
<Reference Include="Newtonsoft.Json, Version=4.0.7.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
4541
<SpecificVersion>False</SpecificVersion>
4642
<HintPath>..\packages\Newtonsoft.Json.4.0.7\lib\net40\Newtonsoft.Json.dll</HintPath>
4743
</Reference>
48-
<Reference Include="SignalR, Version=0.3.6.0, Culture=neutral, processorArchitecture=MSIL">
49-
<SpecificVersion>False</SpecificVersion>
50-
<HintPath>..\lib\SignalR.dll</HintPath>
44+
<Reference Include="SignalR, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
45+
<HintPath>..\packages\SignalR.Server.0.4.0.0\lib\net40\SignalR.dll</HintPath>
5146
</Reference>
5247
<Reference Include="System" />
5348
<Reference Include="System.Core" />

JabbR.Test/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
43
<package id="Moq" version="4.0.10827" />
54
<package id="Newtonsoft.Json" version="4.0.7" />
6-
<package id="SignalR.Server" version="0.3.3" />
5+
<package id="SignalR.Server" version="0.4.0.0" />
76
<package id="xunit" version="1.9.0.1566" />
87
</packages>

JabbR/JabbR.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,19 @@
6161
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
6262
</Reference>
6363
<Reference Include="Newtonsoft.Json, Version=4.0.7.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
64-
<SpecificVersion>False</SpecificVersion>
6564
<HintPath>..\packages\Newtonsoft.Json.4.0.7\lib\net40\Newtonsoft.Json.dll</HintPath>
6665
</Reference>
67-
<Reference Include="Ninject">
66+
<Reference Include="Ninject, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
6867
<HintPath>..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll</HintPath>
6968
</Reference>
70-
<Reference Include="SignalR">
71-
<HintPath>..\lib\SignalR.dll</HintPath>
69+
<Reference Include="SignalR, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
70+
<HintPath>..\packages\SignalR.Server.0.4.0.0\lib\net40\SignalR.dll</HintPath>
7271
</Reference>
73-
<Reference Include="SignalR.Hosting.AspNet">
74-
<HintPath>..\lib\SignalR.Hosting.AspNet.dll</HintPath>
72+
<Reference Include="SignalR.Hosting.AspNet, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
73+
<HintPath>..\packages\SignalR.Hosting.AspNet.0.4.0.0\lib\net40\SignalR.Hosting.AspNet.dll</HintPath>
7574
</Reference>
7675
<Reference Include="SignalR.Ninject, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
77-
<HintPath>..\lib\SignalR.Ninject.dll</HintPath>
76+
<HintPath>..\packages\SignalR.Ninject.0.4\lib\net40\SignalR.Ninject.dll</HintPath>
7877
</Reference>
7978
<Reference Include="System.ComponentModel.Composition" />
8079
<Reference Include="System.ComponentModel.DataAnnotations" />
@@ -97,8 +96,9 @@
9796
<Reference Include="System.Configuration" />
9897
<Reference Include="System.Web.Services" />
9998
<Reference Include="System.EnterpriseServices" />
100-
<Reference Include="WebActivator">
101-
<HintPath>..\packages\WebActivator.1.4.4\lib\net40\WebActivator.dll</HintPath>
99+
<Reference Include="WebActivator, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
100+
<SpecificVersion>False</SpecificVersion>
101+
<HintPath>..\packages\WebActivator.1.5\lib\net40\WebActivator.dll</HintPath>
102102
</Reference>
103103
</ItemGroup>
104104
<ItemGroup>

JabbR/Scripts/jquery.signalR.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
onReconnect: "onReconnect",
2525
onDisconnect: "onDisconnect"
2626
},
27-
log = function (msg) {
27+
log = function (msg, logging) {
28+
if (logging === false) {
29+
return;
30+
}
2831
var m;
2932
if (typeof (window.console) === "undefined") {
3033
return;
@@ -37,25 +40,34 @@
3740
}
3841
};
3942

40-
signalR = function (url, qs) {
43+
signalR = function (url, qs, logging) {
4144
/// <summary>Creates a new SignalR connection for the given url</summary>
4245
/// <param name="url" type="String">The URL of the long polling endpoint</param>
4346
/// <param name="qs" type="Object">
4447
/// [Optional] Custom querystring parameters to add to the connection URL.
4548
/// If an object, every non-function member will be added to the querystring.
4649
/// If a string, it's added to the QS as specified.
4750
/// </param>
51+
/// <param name="logging" type="Boolean">
52+
/// [Optional] A flag indicating whether connection logging is enabled to the browser
53+
/// console/log. Defaults to false.
54+
/// </param>
4855
/// <returns type="signalR" />
4956

50-
return new signalR.fn.init(url, qs);
57+
return new signalR.fn.init(url, qs, logging);
5158
};
5259

5360
signalR.fn = signalR.prototype = {
54-
init: function (url, qs) {
61+
init: function (url, qs, logging) {
5562
this.url = url;
5663
this.qs = qs;
64+
if (typeof (logging) === "boolean") {
65+
this.logging = logging;
66+
}
5767
},
5868

69+
logging: false,
70+
5971
reconnectDelay: 2000,
6072

6173
start: function (options, callback) {
@@ -353,7 +365,7 @@
353365

354366
if (data) {
355367
if (data.Disconnect) {
356-
log("disconnect command received from server");
368+
log("Disconnect command received from server", connection.logging);
357369

358370
// Disconnected by the server
359371
connection.stop();
@@ -369,7 +381,7 @@
369381
$connection.trigger(events.onReceived, [this]);
370382
}
371383
catch (e) {
372-
log("Error raising received " + e);
384+
log("Error raising received " + e, connection.logging);
373385
$(connection).trigger(events.onError, [e]);
374386
}
375387
});
@@ -461,7 +473,7 @@
461473
$connection.trigger(events.onReceived, [this]);
462474
}
463475
catch (e) {
464-
log("Error raising received " + e);
476+
log("Error raising received " + e, connection.logging);
465477
}
466478
});
467479
} else {
@@ -512,7 +524,7 @@
512524
connection.eventSource = new window.EventSource(url);
513525
}
514526
catch (e) {
515-
log("EventSource failed trying to connect with error " + e.Message);
527+
log("EventSource failed trying to connect with error " + e.Message, connection.logging);
516528
if (onFailed) {
517529
// The connection failed, call the failed callback
518530
onFailed();
@@ -521,7 +533,7 @@
521533
$connection.trigger(events.onError, [e]);
522534
if (reconnecting) {
523535
// If we were reconnecting, rather than doing initial connect, then try reconnect again
524-
log("EventSource reconnecting");
536+
log("EventSource reconnecting", connection.logging);
525537
that.reconnect(connection);
526538
}
527539
}
@@ -532,15 +544,15 @@
532544
// and raise on failed
533545
connectTimeOut = window.setTimeout(function () {
534546
if (opened === false) {
535-
log("EventSource timed out trying to connect");
547+
log("EventSource timed out trying to connect", connection.logging);
536548

537549
if (onFailed) {
538550
onFailed();
539551
}
540552

541553
if (reconnecting) {
542554
// If we were reconnecting, rather than doing initial connect, then try reconnect again
543-
log("EventSource reconnecting");
555+
log("EventSource reconnecting", connection.logging);
544556
that.reconnect(connection);
545557
} else {
546558
that.stop(connection);
@@ -550,7 +562,7 @@
550562
that.timeOut);
551563

552564
connection.eventSource.addEventListener("open", function (e) {
553-
log("EventSource connected");
565+
log("EventSource connected", connection.logging);
554566

555567
if (connectTimeOut) {
556568
window.clearTimeout(connectTimeOut);
@@ -585,7 +597,7 @@
585597
return;
586598
}
587599

588-
log("EventSource readyState: " + connection.eventSource.readyState);
600+
log("EventSource readyState: " + connection.eventSource.readyState, connection.logging);
589601

590602
if (e.eventPhase === window.EventSource.CLOSED) {
591603
// connection closed
@@ -594,18 +606,18 @@
594606
// doesn't allow us to change the URL when reconnecting. We need
595607
// to change the URL to not include the /connect suffix, and pass
596608
// the last message id we received.
597-
log("EventSource reconnecting due to the server connection ending");
609+
log("EventSource reconnecting due to the server connection ending", connection.logging);
598610
that.reconnect(connection);
599611
}
600612
else {
601613
// The EventSource has closed, either because its close() method was called,
602614
// or the server sent down a "don't reconnect" frame.
603-
log("EventSource closed");
615+
log("EventSource closed", connection.logging);
604616
that.stop(connection);
605617
}
606618
} else {
607619
// connection error
608-
log("EventSource error");
620+
log("EventSource error", connection.logging);
609621
$connection.trigger(events.onError);
610622
}
611623
}, false);
@@ -663,7 +675,7 @@
663675

664676
frame.bind("readystatechange", function () {
665677
if ($.inArray(this.readyState, ["loaded", "complete"]) >= 0) {
666-
log("Forever frame iframe readyState changed to " + this.readyState + ", reconnecting");
678+
log("Forever frame iframe readyState changed to " + this.readyState + ", reconnecting", connection.logging);
667679
that.reconnect(connection);
668680
}
669681
});

0 commit comments

Comments
 (0)