Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/SignalR/SignalR
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed May 10, 2012
2 parents f4f83f9 + 84871bf commit 939dddb
Show file tree
Hide file tree
Showing 34 changed files with 280 additions and 121 deletions.
18 changes: 10 additions & 8 deletions Build/Build.proj
Expand Up @@ -15,11 +15,13 @@
<DocuExePath>$(ToolsPath)docu\docu.exe</DocuExePath>
<ZipExe>$(ToolsPath)7za920\7za.exe</ZipExe>
<ScriptTempPath>$(ProjectRoot)\SignalR\bin\Scripts</ScriptTempPath>
<PrereleaseTagWithSeparator Condition="$(PrereleaseTag) != ''">-$(PrereleaseTag)</PrereleaseTagWithSeparator>
</PropertyGroup>

<PropertyGroup>
<MajorVersion>0</MajorVersion>
<MinorVersion>5</MinorVersion>
<PackageBuild>1</PackageBuild>
</PropertyGroup>

<PropertyGroup Condition="$(BUILD_NUMBER) != ''">
Expand All @@ -36,20 +38,20 @@
<Revision>0</Revision>
</PropertyGroup>

<PropertyGroup>
<PropertyGroup>
<Version>$(MajorVersion).$(MinorVersion).$(Revision).$(Build)</Version>
<PackageVersion>$(MajorVersion).$(MinorVersion).$(Revision)-rc</PackageVersion>
<JsVersion>$(MajorVersion).$(MinorVersion)rc</JsVersion>
<PackageVersion>$(MajorVersion).$(MinorVersion).$(PackageBuild)$(PrereleaseTagWithSeparator)</PackageVersion>
<JsVersion>$(MajorVersion).$(MinorVersion).$(PackageBuild)$(PrereleaseTag)</JsVersion>
</PropertyGroup>

<ItemGroup>
<RegexTransform Include="$(ProjectRoot)\Common\CommonAssemblyInfo.cs">
<Find>\d+\.\d+\.\d+\.\d+</Find>
<ReplaceWith>$(Version)</ReplaceWith>
</RegexTransform>
<RegexTransform Include="$(ProjectRoot)\Common\CommonAssemblyInfo.cs">
<Find>\d+\.\d+\.\d+-pre</Find>
<ReplaceWith>$(PackageVersion)</ReplaceWith>
<Find>AssemblyInformationalVersion\("\d+\.\d+\.\d+.\d+"\)</Find>
<ReplaceWith>AssemblyInformationalVersion("$(PackageVersion)")</ReplaceWith>
</RegexTransform>
<RegexTransform Include="$(ProjectRoot)\**\AssemblyInfo.cs">
<Find>\d+\.\d+\.\d+\.\d+</Find>
Expand Down Expand Up @@ -105,7 +107,7 @@

<MSBuild Projects="$(ProjectRoot)\SignalR.Silverlight.sln"
Targets="Build"
Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v4.0') And Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v5.0')"
Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v4.0') And Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.CSharp.targets')"
Properties="Configuration=$(Configuration)" />
</Target>

Expand Down Expand Up @@ -151,7 +153,7 @@

<MSBuild Projects="$(ProjectRoot)\SignalR.Client.Silverlight5\SignalR.Client.Silverlight5.csproj"
Targets="Build"
Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v5.0')"
Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.CSharp.targets')"
Properties="BuildPackage=true;Version=$(PackageVersion);PackageOutputDir=$(ArtifactsDir);Configuration=$(Configuration)" />

<RemoveDir Directories="$(ScriptTempPath)" />
Expand Down
4 changes: 2 additions & 2 deletions Common/CommonAssemblyInfo.cs
Expand Up @@ -10,5 +10,5 @@
[assembly: AssemblyCulture("")]
[assembly: AssemblyConfiguration("")]

[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0-pre")]
[assembly: AssemblyFileVersion("0.5.1.0")]
[assembly: AssemblyInformationalVersion("0.5.1.0")]
7 changes: 7 additions & 0 deletions ReleaseNotes.md
@@ -1,5 +1,12 @@
# SignalR Release Notes

## v0.5.0 (Official Release)
* Server Send Events connections not closing ([#369](https://github.com/SignalR/SignalR/issues/369))
* Allow HubConnection to specify hub url ([#368](https://github.com/SignalR/SignalR/issues/368))
* Added current IPrincipal to IRequest. ([e381ef1cb6](https://github.com/SignalR/SignalR/commit/e381ef1cb6c0c13087c221abdfa2833c0ae841a6))
* Remove implicit Send overload from PersistentConnection. ([44ff03aafa](https://github.com/SignalR/SignalR/commit/44ff03aafa5f5e2f3b73a5a19ac5a2437674891b))
* Regression: Method overloads no longer work in hubs because of caching. ([#362](https://github.com/SignalR/SignalR/issues/362))

## v0.5.84 RC (Stable Prerelease)
* Performance: Only register for disconnect for chunked requests on self host. (#352)
* Provide way to override default resolver in ASP.NET other than through routing. (#347)
Expand Down
49 changes: 46 additions & 3 deletions SignalR.Client/Hubs/HubConnection.cs
Expand Up @@ -8,12 +8,49 @@

namespace SignalR.Client.Hubs
{
/// <summary>
/// A <see cref="Connection"/> for interacting with Hubs.
/// </summary>
public class HubConnection : Connection
{
private readonly Dictionary<string, HubProxy> _hubs = new Dictionary<string, HubProxy>(StringComparer.OrdinalIgnoreCase);

/// <summary>
/// Initializes a new instance of the <see cref="HubConnection"/> class.
/// </summary>
/// <param name="url">The url to connect to.</param>
public HubConnection(string url)
: base(GetUrl(url))
: this(url, useDefaultUrl: true)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="HubConnection"/> class.
/// </summary>
/// <param name="url">The url to connect to.</param>
/// <param name="useDefaultUrl">Determines if the default "/signalr" path should be appended to the specified url.</param>
public HubConnection(string url, bool useDefaultUrl)
: base(GetUrl(url, useDefaultUrl))
{
}

/// <summary>
/// Initializes a new instance of the <see cref="HubConnection"/> class.
/// </summary>
/// <param name="url">The url to connect to.</param>
/// <param name="queryString">The query string data to pass to the server.</param>
public HubConnection(string url, string queryString)
: base(url, queryString)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="HubConnection"/> class.
/// </summary>
/// <param name="url">The url to connect to.</param>
/// <param name="queryString">The query string data to pass to the server.</param>
public HubConnection(string url, IDictionary<string, string> queryString)
: base(url, queryString)
{
}

Expand Down Expand Up @@ -75,13 +112,19 @@ private string OnConnectionSending()
return JsonConvert.SerializeObject(data);
}

private static string GetUrl(string url)
private static string GetUrl(string url, bool useDefaultUrl)
{
if (!url.EndsWith("/"))
{
url += "/";
}
return url + "signalr";

if (useDefaultUrl)
{
return url + "signalr";
}

return url;
}
}
}
2 changes: 1 addition & 1 deletion SignalR.Client/Properties/VersionInfo.cs
@@ -1,3 +1,3 @@
using System.Reflection;

[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyVersion("0.5.1.0")]
7 changes: 3 additions & 4 deletions SignalR.Hosting.AspNet/AspNetHandler.cs
Expand Up @@ -3,7 +3,6 @@
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using SignalR.Infrastructure;

namespace SignalR.Hosting.AspNet
{
Expand All @@ -20,7 +19,7 @@ public class AspNetHandler : HttpTaskAsyncHandler
{
return typeof(HttpContextBase).GetMethods().Any(m => m.Name.Equals("AcceptWebSocketRequest", StringComparison.OrdinalIgnoreCase));
});

public AspNetHandler(IDependencyResolver resolver, PersistentConnection connection)
{
_resolver = resolver;
Expand All @@ -29,9 +28,9 @@ public AspNetHandler(IDependencyResolver resolver, PersistentConnection connecti

public override Task ProcessRequestAsync(HttpContextBase context)
{
var request = new AspNetRequest(context.Request);
var request = new AspNetRequest(context.Request, context.User);
var response = new AspNetResponse(context);
var hostContext = new HostContext(request, response, context.User);
var hostContext = new HostContext(request, response);

// Determine if the client should bother to try a websocket request
hostContext.Items[HostConstants.SupportsWebSockets] = _hasAcceptWebSocketRequest.Value;
Expand Down
20 changes: 12 additions & 8 deletions SignalR.Hosting.AspNet/AspNetRequest.cs
@@ -1,25 +1,25 @@
using System;
using System.Collections.Specialized;
using System.Reflection;
using System.Security.Principal;
using System.Web;

namespace SignalR.Hosting.AspNet
{
public class AspNetRequest : IRequest
{
private readonly HttpRequestBase _request;
private readonly HttpCookieCollectionWrapper _cookies;
private NameValueCollection _form;
private NameValueCollection _queryString;

private delegate void GetUnvalidatedCollections(HttpContext context, out Func<NameValueCollection> formGetter, out Func<NameValueCollection> queryStringGetter);
private static Lazy<GetUnvalidatedCollections> _extractCollectionsMethod = new Lazy<GetUnvalidatedCollections>(ResolveCollectionsMethod);

public AspNetRequest(HttpRequestBase request)
public AspNetRequest(HttpRequestBase request, IPrincipal user)
{
_request = request;
_cookies = new HttpCookieCollectionWrapper(request.Cookies);

Cookies = new HttpCookieCollectionWrapper(request.Cookies);
User = user;
ResolveFormAndQueryString();
}

Expand Down Expand Up @@ -57,10 +57,14 @@ public NameValueCollection Form

public IRequestCookieCollection Cookies
{
get
{
return _cookies;
}
get;
private set;
}

public IPrincipal User
{
get;
private set;
}

private void ResolveFormAndQueryString()
Expand Down
5 changes: 1 addition & 4 deletions SignalR.Hosting.AspNet/AspNetShutDownDetector.cs
Expand Up @@ -29,10 +29,7 @@ public void Stop(bool immediate)
{
try
{
if (!immediate)
{
_onShutdown();
}
_onShutdown();
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion SignalR.Hosting.Memory/MemoryHost.cs
Expand Up @@ -48,7 +48,7 @@ private Task<IClientResponse> ProcessRequest(string url, Action<IClientRequest>

Response response = null;
response = new Response(clientTokenSource.Token, () => tcs.TrySetResult(response));
var hostContext = new HostContext(request, response, null);
var hostContext = new HostContext(request, response);

connection.Initialize(DependencyResolver);

Expand Down
9 changes: 9 additions & 0 deletions SignalR.Hosting.Memory/Request.cs
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Security.Principal;
using System.Threading;
using SignalR.Hosting.Common;

Expand Down Expand Up @@ -92,5 +93,13 @@ public IRequestCookieCollection Cookies
get;
private set;
}

public IPrincipal User
{
get
{
return Thread.CurrentPrincipal;
}
}
}
}
2 changes: 1 addition & 1 deletion SignalR.Hosting.Owin/OwinHost.cs
Expand Up @@ -153,7 +153,7 @@ private static AppDelegate ExecuteConnection(Func<IDictionary<string,object>, Pe
{
var request = new OwinRequest(environment, task.Result);
var response = new OwinResponse(result);
var hostContext = new HostContext(request, response, Thread.CurrentPrincipal);
var hostContext = new HostContext(request, response);
try
{
Expand Down
10 changes: 10 additions & 0 deletions SignalR.Hosting.Owin/OwinRequest.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Security.Principal;
using System.Threading;
using Gate;
using SignalR.Hosting.Common;

Expand Down Expand Up @@ -63,6 +65,14 @@ public Uri Url
private set;
}

public IPrincipal User
{
get
{
return Thread.CurrentPrincipal;
}
}

/// <summary>
/// Based on http://owin.org/spec/owin-1.0.0draft5.html#URIReconstruction
/// </summary>
Expand Down
10 changes: 9 additions & 1 deletion SignalR.Hosting.Self/HttpListenerRequestWrapper.cs
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Net;
using SignalR.Hosting.Common;
using System.Security.Principal;

namespace SignalR.Hosting.Self
{
Expand All @@ -14,12 +15,13 @@ public class HttpListenerRequestWrapper : IRequest
private readonly NameValueCollection _headers;
private readonly CookieCollectionWrapper _cookies;

public HttpListenerRequestWrapper(HttpListenerRequest httpListenerRequest)
public HttpListenerRequestWrapper(HttpListenerRequest httpListenerRequest, IPrincipal user)
{
_httpListenerRequest = httpListenerRequest;
_qs = new NameValueCollection(httpListenerRequest.QueryString);
_headers = new NameValueCollection(httpListenerRequest.Headers);
_cookies = new CookieCollectionWrapper(_httpListenerRequest.Cookies);
User = user;
}

public IRequestCookieCollection Cookies
Expand Down Expand Up @@ -63,6 +65,12 @@ public NameValueCollection QueryString
}
}

public IPrincipal User
{
get;
private set;
}

private void EnsureForm()
{
if (_form == null)
Expand Down
4 changes: 2 additions & 2 deletions SignalR.Hosting.Self/Server.cs
Expand Up @@ -152,9 +152,9 @@ private Task ProcessRequestAsync(HttpListenerContext context)
{
var cts = new CancellationTokenSource();

var request = new HttpListenerRequestWrapper(context.Request);
var request = new HttpListenerRequestWrapper(context.Request, context.User);
var response = new HttpListenerResponseWrapper(context.Response, () => RegisterForDisconnect(context, cts.Cancel), cts.Token);
var hostContext = new HostContext(request, response, context.User);
var hostContext = new HostContext(request, response);

if (OnProcessRequest != null)
{
Expand Down
2 changes: 1 addition & 1 deletion SignalR.Tests/DisconnectFacts.cs
Expand Up @@ -166,7 +166,7 @@ protected override Task OnDisconnectAsync(string connectionId)
return base.OnDisconnectAsync(connectionId);
}

protected override Task OnReceivedAsync(string connectionId, string data)
protected override Task OnReceivedAsync(Hosting.IRequest request, string connectionId, string data)
{
return Connection.Broadcast(data);
}
Expand Down

0 comments on commit 939dddb

Please sign in to comment.