Skip to content

Commit

Permalink
Adding client for .net 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
robink-teleopti authored and davidfowl committed Jun 17, 2012
1 parent 7ba2c26 commit 9e3a95c
Show file tree
Hide file tree
Showing 22 changed files with 467 additions and 12 deletions.
18 changes: 18 additions & 0 deletions SignalR.Client.Net35/IObserver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SignalR.Client
{
public interface IObserver<T>
{
void OnCompleted();
void OnError(Exception exception);
void OnNext(T value);
}

public interface IObservable<T>
{
}
}
4 changes: 4 additions & 0 deletions SignalR.Client.Net35/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using System.Reflection;

[assembly: AssemblyTitle("SignalR.Client.Net35")]
[assembly: AssemblyDescription(".NET 3.5 client for SignalR")]
12 changes: 12 additions & 0 deletions SignalR.Client.Net35/Properties/SignalR.Client.Net35.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<package>
<metadata>
<id>$id$</id>
<version>$version$</version>
<authors>$author$</authors>
<description>$description$</description>
<licenseUrl>https://github.com/SignalR/SignalR/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/SignalR/SignalR</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
</metadata>
</package>
3 changes: 3 additions & 0 deletions SignalR.Client.Net35/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Reflection;

[assembly: AssemblyVersion("0.5.1.0")]
170 changes: 170 additions & 0 deletions SignalR.Client.Net35/SignalR.Client.Net35.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{42DE29B3-67CA-4003-A4F6-CA4F21C8991C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SignalR.Client.Net35</RootNamespace>
<AssemblyName>SignalR.Client.Net35</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET35</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NET35</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.5.6\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Threading.Tasks.NET35">
<HintPath>..\packages\System.Threading.Tasks.3.0.1\lib\net35\System.Threading.Tasks.NET35.dll</HintPath>
<Aliases>global</Aliases>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Common\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Connection.cs">
<Link>Connection.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\ConnectionExtensions.cs">
<Link>ConnectionExtensions.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\ConnectionState.cs">
<Link>ConnectionState.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\DefaultHttpClient.cs">
<Link>Http\DefaultHttpClient.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\HttpHelper.cs">
<Link>Http\HttpHelper.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\HttpWebRequestWrapper.cs">
<Link>Http\HttpWebRequestWrapper.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\HttpWebResponseWrapper.cs">
<Link>Http\HttpWebResponseWrapper.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\IHttpClient.cs">
<Link>Http\IHttpClient.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\IHttpClientExtensions.cs">
<Link>Http\IHttpClientExtensions.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\IRequest.cs">
<Link>Http\IRequest.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Http\IResponse.cs">
<Link>Http\IResponse.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\HubConnection.cs">
<Link>Hubs\HubConnection.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\HubInvocation.cs">
<Link>Hubs\HubInvocation.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\HubProxy.cs">
<Link>Hubs\HubProxy.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\HubProxyExtensions.cs">
<Link>Hubs\HubProxyExtensions.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\HubRegistrationData.cs">
<Link>Hubs\HubRegistrationData.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\HubResult.cs">
<Link>Hubs\HubResult.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\Hubservable.cs">
<Link>Hubs\Hubservable.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\IHubProxy.cs">
<Link>Hubs\IHubProxy.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Hubs\Subscription.cs">
<Link>Hubs\Subscription.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\IConnection.cs">
<Link>IConnection.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Infrastructure\ChunkBuffer.cs">
<Link>Infrastructure\ChunkBuffer.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Infrastructure\DisposableAction.cs">
<Link>Infrastructure\DisposableAction.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Infrastructure\StreamExtensions.cs">
<Link>Infrastructure\StreamExtensions.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\NegotiationResponse.cs">
<Link>NegotiationResponse.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\ObservableConnection.cs">
<Link>ObservableConnection.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Transports\AutoTransport.cs">
<Link>Transports\AutoTransport.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Transports\HttpBasedTransport.cs">
<Link>Transports\HttpBasedTransport.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Transports\IClientTransport.cs">
<Link>Transports\IClientTransport.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Transports\LongPollingTransport.cs">
<Link>Transports\LongPollingTransport.cs</Link>
</Compile>
<Compile Include="..\SignalR.Client\Transports\ServerSentEventsTransport.cs">
<Link>Transports\ServerSentEventsTransport.cs</Link>
</Compile>
<Compile Include="..\SignalR.Hosting.Common\Infrastructure\UriQueryUtility.cs">
<Link>Infrastructure\UriQueryUtility.cs</Link>
</Compile>
<Compile Include="..\SignalR\TaskAsyncHelper.cs">
<Link>Infrastructure\TaskAsyncHelper.cs</Link>
</Compile>
<Compile Include="IObserver.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\VersionInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Properties\SignalR.Client.Net35.nuspec">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
5 changes: 5 additions & 0 deletions SignalR.Client.Net35/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.6" />
<package id="System.Threading.Tasks" version="3.0.1" />
</packages>
2 changes: 1 addition & 1 deletion SignalR.Client/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ private static string CreateUserAgentString(string client)

private static bool TryParseVersion(string versionString, out Version version)
{
#if WINDOWS_PHONE
#if WINDOWS_PHONE || NET35
try
{
version = new Version(versionString);
Expand Down
6 changes: 5 additions & 1 deletion SignalR.Client/Http/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ public static string ReadAsString(this HttpWebResponse response)
}
catch (Exception ex)
{
Debug.WriteLine("Failed to read resonse: {0}", ex);
#if NET35
Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Failed to read response: {0}", ex));
#else
Debug.WriteLine("Failed to read response: {0}", ex);
#endif
// Swallow exceptions when reading the response stream and just try again.
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions SignalR.Client/Hubs/HubProxy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
#if !WINDOWS_PHONE
#if !WINDOWS_PHONE && !NET35
using System.Dynamic;
#endif
using System.Threading.Tasks;
Expand All @@ -9,7 +9,7 @@
namespace SignalR.Client.Hubs
{
public class HubProxy :
#if !WINDOWS_PHONE
#if !WINDOWS_PHONE && !NET35
DynamicObject,
#endif
IHubProxy
Expand Down Expand Up @@ -101,7 +101,7 @@ public Task<T> Invoke<T>(string method, params object[] args)
});
}

#if !WINDOWS_PHONE
#if !WINDOWS_PHONE && !NET35
public override bool TrySetMember(SetMemberBinder binder, object value)
{
_state[binder.Name] = value;
Expand Down
2 changes: 1 addition & 1 deletion SignalR.Client/Hubs/HubProxyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static IDisposable On<T1, T2, T3, T4>(this IHubProxy proxy, string eventN
return new DisposableAction(() => subscription.Data -= handler);
}

#if !WINDOWS_PHONE && !SILVERLIGHT
#if !WINDOWS_PHONE && !SILVERLIGHT && !NET35
/// <summary>
/// Registers for an event with the specified name and callback
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions SignalR.Client/Transports/AutoTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ private void ResolveTransport(IConnection connection, CancellationToken cancella
#if !WINDOWS_PHONE && !SILVERLIGHT && !NETFX_CORE
Trace.TraceError("SignalR exception thrown by Task: {0}", ex);
#endif
#if NET35
Debug.WriteLine(System.String.Format(System.Globalization.CultureInfo.InvariantCulture, "Auto: Failed to connect to using transport {0}", (object)transport.GetType().Name));
#else
Debug.WriteLine("Auto: Failed to connect to using transport {0}", (object)transport.GetType().Name);
#endif
// If that transport fails to initialize then fallback
var next = index + 1;
Expand Down
9 changes: 9 additions & 0 deletions SignalR.Client/Transports/HttpBasedTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ protected static void ProcessResponse(IConnection connection, string response, o
}
catch (Exception ex)
{
#if NET35
Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Failed to process message: {0}", ex));
#else
Debug.WriteLine("Failed to process message: {0}", ex);
#endif

connection.OnError(ex);
}
}
Expand All @@ -247,7 +252,11 @@ protected static void ProcessResponse(IConnection connection, string response, o
}
catch (Exception ex)
{
#if NET35
Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Failed to response: {0}", ex));
#else
Debug.WriteLine("Failed to response: {0}", ex);
#endif
connection.OnError(ex);
}
}
Expand Down
8 changes: 8 additions & 0 deletions SignalR.Client/Transports/LongPollingTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ private void PollingLoop(IConnection connection, string data, Action initializeC

url += GetReceiveQueryString(connection, data);

#if NET35
Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "LP: {0}", (object)url));
#else
Debug.WriteLine("LP: {0}", (object)url);
#endif

_httpClient.PostAsync(url, PrepareRequest(connection)).ContinueWith(task =>
{
Expand All @@ -75,7 +79,11 @@ private void PollingLoop(IConnection connection, string data, Action initializeC
// Get the response
var raw = task.Result.ReadAsString();
#if NET35
Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "LP Receive: {0}", (object)raw));
#else
Debug.WriteLine("LP Receive: {0}", (object)raw);
#endif
ProcessResponse(connection, raw, out shouldRaiseReconnect, out disconnectedReceived);
}
Expand Down
2 changes: 1 addition & 1 deletion SignalR.Client/Transports/ServerSentEvents/ChunkBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public string ReadLine()
_buffer.Remove(0, _offset + 1);

string line = _lineBuilder.ToString();
#if WINDOWS_PHONE
#if WINDOWS_PHONE || NET35
_lineBuilder.Length = 0;
#else
_lineBuilder.Clear();
Expand Down
4 changes: 4 additions & 0 deletions SignalR.Client/Transports/ServerSentEventsTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ private void OpenConnection(IConnection connection, string data, Action initiali

Action<IRequest> prepareRequest = PrepareRequest(connection);

#if NET35
Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "SSE: GET {0}", (object)url));
#else
Debug.WriteLine("SSE: GET {0}", (object)url);
#endif

_httpClient.GetAsync(url, request =>
{
Expand Down
Loading

0 comments on commit 9e3a95c

Please sign in to comment.