Skip to content

Commit

Permalink
Updated to official signalr 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Feb 7, 2012
1 parent fc4c100 commit 7dd6450
Showing 9 changed files with 48 additions and 41 deletions.
9 changes: 2 additions & 7 deletions JabbR.Test/JabbR.Test.csproj
Original file line number Diff line number Diff line change
@@ -34,20 +34,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.0.7.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.0.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SignalR, Version=0.3.6.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\SignalR.dll</HintPath>
<Reference Include="SignalR, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SignalR.Server.0.4.0.0\lib\net40\SignalR.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
3 changes: 1 addition & 2 deletions JabbR.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="Moq" version="4.0.10827" />
<package id="Newtonsoft.Json" version="4.0.7" />
<package id="SignalR.Server" version="0.3.3" />
<package id="SignalR.Server" version="0.4.0.0" />
<package id="xunit" version="1.9.0.1566" />
</packages>
18 changes: 9 additions & 9 deletions JabbR/JabbR.csproj
Original file line number Diff line number Diff line change
@@ -61,20 +61,19 @@
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.0.7.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.0.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Ninject">
<Reference Include="Ninject, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll</HintPath>
</Reference>
<Reference Include="SignalR">
<HintPath>..\lib\SignalR.dll</HintPath>
<Reference Include="SignalR, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SignalR.Server.0.4.0.0\lib\net40\SignalR.dll</HintPath>
</Reference>
<Reference Include="SignalR.Hosting.AspNet">
<HintPath>..\lib\SignalR.Hosting.AspNet.dll</HintPath>
<Reference Include="SignalR.Hosting.AspNet, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SignalR.Hosting.AspNet.0.4.0.0\lib\net40\SignalR.Hosting.AspNet.dll</HintPath>
</Reference>
<Reference Include="SignalR.Ninject, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\lib\SignalR.Ninject.dll</HintPath>
<HintPath>..\packages\SignalR.Ninject.0.4\lib\net40\SignalR.Ninject.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
@@ -97,8 +96,9 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="WebActivator">
<HintPath>..\packages\WebActivator.1.4.4\lib\net40\WebActivator.dll</HintPath>
<Reference Include="WebActivator, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\WebActivator.1.5\lib\net40\WebActivator.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
46 changes: 29 additions & 17 deletions JabbR/Scripts/jquery.signalR.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,10 @@
onReconnect: "onReconnect",
onDisconnect: "onDisconnect"
},
log = function (msg) {
log = function (msg, logging) {
if (logging === false) {
return;
}
var m;
if (typeof (window.console) === "undefined") {
return;
@@ -37,25 +40,34 @@
}
};

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

return new signalR.fn.init(url, qs);
return new signalR.fn.init(url, qs, logging);
};

signalR.fn = signalR.prototype = {
init: function (url, qs) {
init: function (url, qs, logging) {
this.url = url;
this.qs = qs;
if (typeof (logging) === "boolean") {
this.logging = logging;
}
},

logging: false,

reconnectDelay: 2000,

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

if (data) {
if (data.Disconnect) {
log("disconnect command received from server");
log("Disconnect command received from server", connection.logging);

// Disconnected by the server
connection.stop();
@@ -369,7 +381,7 @@
$connection.trigger(events.onReceived, [this]);
}
catch (e) {
log("Error raising received " + e);
log("Error raising received " + e, connection.logging);
$(connection).trigger(events.onError, [e]);
}
});
@@ -461,7 +473,7 @@
$connection.trigger(events.onReceived, [this]);
}
catch (e) {
log("Error raising received " + e);
log("Error raising received " + e, connection.logging);
}
});
} else {
@@ -512,7 +524,7 @@
connection.eventSource = new window.EventSource(url);
}
catch (e) {
log("EventSource failed trying to connect with error " + e.Message);
log("EventSource failed trying to connect with error " + e.Message, connection.logging);
if (onFailed) {
// The connection failed, call the failed callback
onFailed();
@@ -521,7 +533,7 @@
$connection.trigger(events.onError, [e]);
if (reconnecting) {
// If we were reconnecting, rather than doing initial connect, then try reconnect again
log("EventSource reconnecting");
log("EventSource reconnecting", connection.logging);
that.reconnect(connection);
}
}
@@ -532,15 +544,15 @@
// and raise on failed
connectTimeOut = window.setTimeout(function () {
if (opened === false) {
log("EventSource timed out trying to connect");
log("EventSource timed out trying to connect", connection.logging);

if (onFailed) {
onFailed();
}

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

connection.eventSource.addEventListener("open", function (e) {
log("EventSource connected");
log("EventSource connected", connection.logging);

if (connectTimeOut) {
window.clearTimeout(connectTimeOut);
@@ -585,7 +597,7 @@
return;
}

log("EventSource readyState: " + connection.eventSource.readyState);
log("EventSource readyState: " + connection.eventSource.readyState, connection.logging);

if (e.eventPhase === window.EventSource.CLOSED) {
// connection closed
@@ -594,18 +606,18 @@
// doesn't allow us to change the URL when reconnecting. We need
// to change the URL to not include the /connect suffix, and pass
// the last message id we received.
log("EventSource reconnecting due to the server connection ending");
log("EventSource reconnecting due to the server connection ending", connection.logging);
that.reconnect(connection);
}
else {
// The EventSource has closed, either because its close() method was called,
// or the server sent down a "don't reconnect" frame.
log("EventSource closed");
log("EventSource closed", connection.logging);
that.stop(connection);
}
} else {
// connection error
log("EventSource error");
log("EventSource error", connection.logging);
$connection.trigger(events.onError);
}
}, false);
@@ -663,7 +675,7 @@

frame.bind("readystatechange", function () {
if ($.inArray(this.readyState, ["loaded", "complete"]) >= 0) {
log("Forever frame iframe readyState changed to " + this.readyState + ", reconnecting");
log("Forever frame iframe readyState changed to " + this.readyState + ", reconnecting", connection.logging);
that.reconnect(connection);
}
});
Loading
Oops, something went wrong.

0 comments on commit 7dd6450

Please sign in to comment.