Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianEdwards committed Mar 27, 2014
2 parents cf30451 + e4f84ba commit b940230
Show file tree
Hide file tree
Showing 75 changed files with 964 additions and 343 deletions.
4 changes: 2 additions & 2 deletions build/Microsoft.AspNet.SignalR.versions.targets
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<MajorVersion>2</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>2</PatchVersion>
<PatchVersion>3</PatchVersion>

<!-- Change this to set the build quality of the project. Use values like "alpha", "beta", "rc1", "rtm", etc. -->
<!-- These values are used in SemVer, so make sure to always increase these alphabetically. -->
Expand All @@ -13,7 +13,7 @@
<KatanaBuildQuality Condition="'$(Nightly)' == 'true'">rtw</KatanaBuildQuality>

<!-- Katana version -->
<KatanaVersion>2.0.0</KatanaVersion>
<KatanaVersion>2.0.1</KatanaVersion>

<!-- Ensure that we come up with a new version every 65535 years -->
<VersionStartYear>2012</VersionStartYear>
Expand Down
2 changes: 1 addition & 1 deletion samples/Microsoft.AspNet.SignalR.Samples/Scripts/hubs.js
@@ -1,5 +1,5 @@
/*!
* ASP.NET SignalR JavaScript Library v2.0.2-pre
* ASP.NET SignalR JavaScript Library v2.0.3-pre
* http://signalr.net/
*
* Copyright Microsoft Open Technologies, Inc. All rights reserved.
Expand Down
4 changes: 2 additions & 2 deletions src/Common/CommonVersionInfo.cs
Expand Up @@ -2,6 +2,6 @@

using System.Reflection;

[assembly: AssemblyVersion("2.0.2")]
[assembly: AssemblyVersion("2.0.3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.2-pre")]
[assembly: AssemblyInformationalVersion("2.0.3-pre")]
18 changes: 9 additions & 9 deletions src/Microsoft.AspNet.SignalR.Client.JS/jquery.signalR.core.js
@@ -1,6 +1,6 @@
/*global window:false */
/*!
* ASP.NET SignalR JavaScript Library v2.0.2-pre
* ASP.NET SignalR JavaScript Library v2.0.3-pre
* http://signalr.net/
*
* Copyright Microsoft Open Technologies, Inc. All rights reserved.
Expand Down Expand Up @@ -204,7 +204,7 @@
$(connection).triggerHandler(events.onError, [error]);
};

if (!connection._.pingIntervalId && config.pingInterval) {
if (config && !connection._.pingIntervalId && config.pingInterval) {
connection._.pingIntervalId = window.setInterval(function () {
signalR.transports._logic.pingServer(connection).fail(onFail);
}, config.pingInterval);
Expand Down Expand Up @@ -332,7 +332,8 @@
lastMessageAt: new Date().getTime(),
lastActiveAt: new Date().getTime(),
beatInterval: 5000, // Default value, will only be overridden if keep alive is enabled,
beatHandle: null
beatHandle: null,
totalTransportConnectTimeout: 0 // This will be the sum of the TransportConnectTimeout sent in response to negotiate and connection.transportConnectTimeout
};
if (typeof (logging) === "boolean") {
this.logging = logging;
Expand Down Expand Up @@ -390,7 +391,7 @@

reconnectDelay: 2000,

transportConnectTimeout: 0, // This will be modified by the server in respone to the negotiate request. It will add any value sent down from the server to the client value.
transportConnectTimeout: 0,

disconnectTimeout: 30000, // This should be set by the server in response to the negotiate request (30s default)

Expand Down Expand Up @@ -499,9 +500,8 @@
connection.log("Auto detected cross domain url.");

if (config.transport === "auto") {
// Try webSockets and longPolling since SSE doesn't support CORS
// TODO: Support XDM with foreverFrame
config.transport = ["webSockets", "longPolling"];
config.transport = ["webSockets", "serverSentEvents", "longPolling"];
}

if (typeof (config.withCredentials) === "undefined") {
Expand Down Expand Up @@ -570,7 +570,7 @@
connection._.onFailedTimeoutHandle = window.setTimeout(function () {
connection.log(transport.name + " timed out when trying to connect.");
onFailed();
}, connection.transportConnectTimeout);
}, connection._.totalTransportConnectTimeout);

transport.start(connection, function () { // success
// Firefox 11+ doesn't allow sync XHR withCredentials: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#withCredentials
Expand Down Expand Up @@ -697,8 +697,8 @@
// after res.DisconnectTimeout seconds.
connection.disconnectTimeout = res.DisconnectTimeout * 1000; // in ms

// If the connection already has a transportConnectTimeout set then keep it, otherwise use the servers value.
connection.transportConnectTimeout = connection.transportConnectTimeout + res.TransportConnectTimeout * 1000;
// Add the TransportConnectTimeout from the response to the transportConnectTimeout from the client to calculate the total timeout
connection._.totalTransportConnectTimeout = connection.transportConnectTimeout + res.TransportConnectTimeout * 1000;

// If we have a keep alive
if (res.KeepAliveTimeout) {
Expand Down
Expand Up @@ -53,11 +53,6 @@
}
}

function isConnectedOrReconnecting(connection) {
return connection.state === signalR.connectionState.connected ||
connection.state === signalR.connectionState.reconnecting;
}

function addConnectionData(url, connectionData) {
var appender = url.indexOf("?") !== -1 ? "&" : "?";

Expand Down Expand Up @@ -412,6 +407,7 @@
},

startHeartbeat: function (connection) {
connection._.lastActiveAt = new Date().getTime();
beat(connection);
},

Expand All @@ -428,6 +424,11 @@
return false;
},

isConnectedOrReconnecting: function (connection) {
return connection.state === signalR.connectionState.connected ||
connection.state === signalR.connectionState.reconnecting;
},

ensureReconnectingState: function (connection) {
if (changeState(connection,
signalR.connectionState.connected,
Expand Down Expand Up @@ -459,7 +460,7 @@

// We should only set a reconnectTimeout if we are currently connected
// and a reconnectTimeout isn't already set.
if (isConnectedOrReconnecting(connection) && !connection._.reconnectTimeout) {
if (transportLogic.isConnectedOrReconnecting(connection) && !connection._.reconnectTimeout) {
// Need to verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
if (!transportLogic.verifyLastActive(connection)) {
return;
Expand Down
Expand Up @@ -43,7 +43,7 @@
attachedTo++;
}
},
cancel: function () {
cancel: function () {
// Only clear the interval if there's only one more object that the loadPreventer is attachedTo
if (attachedTo === 1) {
window.clearInterval(loadingFixIntervalId);
Expand All @@ -70,7 +70,7 @@
url,
frame = createFrame(),
frameLoadHandler = function () {
connection.log("Forever frame iframe finished loading and is no longer receiving messages, reconnecting.");
connection.log("Forever frame iframe finished loading and is no longer receiving messages.");
that.reconnect(connection);
};

Expand Down Expand Up @@ -121,24 +121,22 @@
reconnect: function (connection) {
var that = this;

// Need to verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
if (!transportLogic.verifyLastActive(connection)) {
return;
}

window.setTimeout(function () {
// Verify that we're ok to reconnect.
if (!transportLogic.verifyLastActive(connection)) {
return;
}
// Need to verify connection state and verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
if (transportLogic.isConnectedOrReconnecting(connection) && transportLogic.verifyLastActive(connection)) {
window.setTimeout(function () {
// Verify that we're ok to reconnect.
if (!transportLogic.verifyLastActive(connection)) {
return;
}

if (connection.frame && transportLogic.ensureReconnectingState(connection)) {
var frame = connection.frame,
src = transportLogic.getUrl(connection, that.name, true) + "&frameId=" + connection.frameId;
connection.log("Updating iframe src to '" + src + "'.");
frame.src = src;
}
}, connection.reconnectDelay);
if (connection.frame && transportLogic.ensureReconnectingState(connection)) {
var frame = connection.frame,
src = transportLogic.getUrl(connection, that.name, true) + "&frameId=" + connection.frameId;
connection.log("Updating iframe src to '" + src + "'.");
frame.src = src;
}
}, connection.reconnectDelay);
}
},

lostConnection: function (connection) {
Expand Down
Expand Up @@ -43,7 +43,7 @@

try {
connection.log("Attempting to connect to SSE endpoint '" + url + "'.");
connection.eventSource = new window.EventSource(url);
connection.eventSource = new window.EventSource(url, { withCredentials: connection.withCredentials });
}
catch (e) {
connection.log("EventSource failed trying to connect with error " + e.Message + ".");
Expand Down
Expand Up @@ -3,5 +3,5 @@
/*global window:false */
/// <reference path="jquery.signalR.core.js" />
(function ($, undefined) {
$.signalR.version = "2.0.2-pre";
$.signalR.version = "2.0.3-pre";
}(window.jQuery));
10 changes: 6 additions & 4 deletions src/Microsoft.AspNet.SignalR.Client/Connection.cs
Expand Up @@ -209,7 +209,7 @@ TimeSpan IConnection.TotalTransportConnectTimeout
/// The maximum amount of time a connection will allow to try and reconnect.
/// This value is equivalent to the summation of the servers disconnect and keep alive timeout values.
/// </summary>
TimeSpan IConnection.ReconnectWindow
TimeSpan IConnection.ReconnectWindow
{
get
{
Expand Down Expand Up @@ -498,9 +498,11 @@ private Task StartTransport()
// Now that we're connected complete the start task that the
// receive queue is waiting on
_startTcs.SetResult(null);
// Start the monitor to check for server activity
_monitor.Start();
_lastMessageAt = DateTime.UtcNow;
_lastActiveAt = DateTime.UtcNow;
_monitor.Start();
})
// Don't return until the last receive has been processed to ensure messages/state sent in OnConnected
// are processed prior to the Start() method task finishing
Expand Down Expand Up @@ -866,7 +868,7 @@ private static string CreateUserAgentString(string client)
if (_assemblyVersion == null)
{
#if NETFX_CORE
_assemblyVersion = new Version("2.0.2");
_assemblyVersion = new Version("2.0.3");
#else
_assemblyVersion = new AssemblyName(typeof(Connection).Assembly.FullName).Version;
#endif
Expand Down
4 changes: 1 addition & 3 deletions src/Microsoft.AspNet.SignalR.Client/HeartBeatMonitor.cs
Expand Up @@ -51,12 +51,10 @@ public HeartbeatMonitor(IConnection connection, object connectionStateLock, Time
}

/// <summary>
/// Updates LastKeepAlive and starts the timer
/// Starts the timer that triggers heartbeats
/// </summary>
public void Start()
{
_connection.MarkLastMessage();
_connection.MarkActive();
_monitorKeepAlive = _connection.KeepAliveData != null && _connection.Transport.SupportsKeepAlive;

HasBeenWarned = false;
Expand Down
Expand Up @@ -48,6 +48,15 @@ public void Abort(IConnection connection, TimeSpan timeout, string connectionDat
throw new ArgumentNullException("connection");
}

// Save the connection.ConnectionToken since race issue that connection.ConnectionToken can be set to null in different thread
var connectionToken = connection.ConnectionToken;

if (connectionToken == null)
{
connection.Trace(TraceLevels.Messages, "Connection already disconnected, skipping abort.");
return;
}

// Abort should never complete before any of its previous calls
lock (_abortLock)
{
Expand All @@ -65,7 +74,7 @@ public void Abort(IConnection connection, TimeSpan timeout, string connectionDat
_abortQueryString,
_transportName,
connectionData,
Uri.EscapeDataString(connection.ConnectionToken),
Uri.EscapeDataString(connectionToken),
null);

url += TransportHelper.AppendCustomQueryString(connection, url);
Expand Down
Expand Up @@ -107,7 +107,7 @@ public Task Send(IConnection connection, string data, string connectionData)
{
connection.Trace(TraceLevels.Messages, "OnMessage({0})", raw);
connection.OnReceived(JObject.Parse(raw));
connection.OnReceived(connection.JsonDeserializeObject<JObject>(raw));
}
})
.Catch(connection.OnError);
Expand Down
Expand Up @@ -151,6 +151,7 @@ public override bool SupportsKeepAlive
if (disconnectedReceived)
{
connection.Trace(TraceLevels.Messages, "Disconnect command received from server.");
connection.Disconnect();
}
};
Expand Down
Expand Up @@ -196,6 +196,7 @@ public void OpenConnection(IConnection connection, Action<Exception> errorCallba
if (disconnected)
{
connection.Trace(TraceLevels.Messages, "Disconnect command received from server.");
_stop = true;
connection.Disconnect();
}
Expand Down
Expand Up @@ -168,7 +168,7 @@ public static void ProcessResponse(IConnection connection, string response, out

try
{
var result = JValue.Parse(response);
var result = connection.JsonDeserializeObject<JObject>(response);

if (!result.HasValues)
{
Expand Down Expand Up @@ -218,7 +218,7 @@ public static bool VerifyLastActive(IConnection connection)
}

// Ensure that we have not exceeded the reconnect window
if(DateTime.UtcNow - connection.LastActiveAt >= connection.ReconnectWindow)
if (DateTime.UtcNow - connection.LastActiveAt >= connection.ReconnectWindow)
{
connection.Trace(TraceLevels.Events, "There has not been an active server connection for an extended period of time. Stopping connection.");
connection.Stop();
Expand Down
Expand Up @@ -43,9 +43,9 @@ public DefaultHttpHandler(IConnection connection)
}

#if !PORTABLE
if (Proxy != null)
if (_connection.Proxy != null)
{
Proxy = Proxy;
Proxy = _connection.Proxy;
}
#endif

Expand Down
Expand Up @@ -169,6 +169,7 @@ public override void OnMessage(string message)

if (disconnected && !_disconnectToken.IsCancellationRequested)
{
_connectionInfo.Connection.Trace(TraceLevels.Messages, "Disconnect command received from server.");
_connectionInfo.Connection.Disconnect();
}
}
Expand Down
Expand Up @@ -25,6 +25,7 @@ public DefaultConfigurationManager()
ConnectionTimeout = TimeSpan.FromSeconds(110);
DisconnectTimeout = TimeSpan.FromSeconds(30);
DefaultMessageBufferSize = 1000;
MaxIncomingWebSocketMessageSize = 64 * 1024; // 64 KB
TransportConnectTimeout = TimeSpan.FromSeconds(5);
LongPollDelay = TimeSpan.Zero;
}
Expand Down Expand Up @@ -88,6 +89,12 @@ public int DefaultMessageBufferSize
set;
}

public int? MaxIncomingWebSocketMessageSize
{
get;
set;
}

public TimeSpan TransportConnectTimeout
{
get;
Expand Down
Expand Up @@ -37,11 +37,18 @@ public interface IConfigurationManager
TimeSpan? KeepAlive { get; set; }

/// <summary>
/// Gets of sets the number of messages to buffer for a specific signal.
/// Gets or sets the number of messages to buffer for a specific signal.
/// The default value is 1000.
/// </summary>
int DefaultMessageBufferSize { get; set; }

/// <summary>
/// Gets or sets the maximum size in bytes of messages sent from client to the server via WebSockets.
/// Set to null to disable this limit.
/// The default value is 65536 or 64 KB.
/// </summary>
int? MaxIncomingWebSocketMessageSize { get; set; }

/// <summary>
/// Gets or sets a <see cref="TimeSpan"/> representing tell the client to wait before restablishing a
/// long poll connection after data is sent from the server.
Expand Down

0 comments on commit b940230

Please sign in to comment.