Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added StateChange type so that it's easier to make the old and new st…

…ate of the

connection available in the event.
  • Loading branch information...
commit a07d1a2b4a0dfbcf264a4f24d3151170521d3464 1 parent ce609f0
@davidfowl davidfowl authored
View
3  SignalR.Client.Silverlight/SignalR.Client.Silverlight.csproj
@@ -77,6 +77,9 @@
<Compile Include="..\SignalR.Client\ConnectionState.cs">
<Link>ConnectionState.cs</Link>
</Compile>
+ <Compile Include="..\SignalR.Client\StateChange.cs">
+ <Link>StateChange.cs</Link>
+ </Compile>
<Compile Include="..\SignalR.Client\Http\DefaultHttpClient.cs">
<Link>Http\DefaultHttpClient.cs</Link>
</Compile>
View
3  SignalR.Client.Silverlight5/SignalR.Client.Silverlight5.csproj
@@ -69,6 +69,9 @@
<Compile Include="..\SignalR.Client\ConnectionState.cs">
<Link>ConnectionState.cs</Link>
</Compile>
+ <Compile Include="..\SignalR.Client\StateChange.cs">
+ <Link>StateChange.cs</Link>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
View
3  SignalR.Client.WP7/SignalR.Client.WP7.csproj
@@ -70,6 +70,9 @@
<Compile Include="..\SignalR.Client\ConnectionState.cs">
<Link>ConnectionState.cs</Link>
</Compile>
+ <Compile Include="..\SignalR.Client\StateChange.cs">
+ <Link>StateChange.cs</Link>
+ </Compile>
<Compile Include="..\SignalR.Client\Http\DefaultHttpClient.cs">
<Link>Http\DefaultHttpClient.cs</Link>
</Compile>
View
3  SignalR.Client.WP71/SignalR.Client.WP71.csproj
@@ -70,6 +70,9 @@
<Compile Include="..\SignalR.Client\ConnectionState.cs">
<Link>ConnectionState.cs</Link>
</Compile>
+ <Compile Include="..\SignalR.Client\StateChange.cs">
+ <Link>StateChange.cs</Link>
+ </Compile>
<Compile Include="..\SignalR.Client\Http\DefaultHttpClient.cs">
<Link>Http\DefaultHttpClient.cs</Link>
</Compile>
View
3  SignalR.Client.WinRT/SignalR.Client.WinRT.csproj
@@ -119,6 +119,9 @@
<Compile Include="..\SignalR.Client\ConnectionState.cs">
<Link>ConnectionState.cs</Link>
</Compile>
+ <Compile Include="..\SignalR.Client\StateChange.cs">
+ <Link>StateChange.cs</Link>
+ </Compile>
<Compile Include="..\SignalR.Client\Http\IHttpClient.cs">
<Link>Http\IHttpClient.cs</Link>
</Compile>
View
6 SignalR.Client/Connection.cs
@@ -45,7 +45,7 @@ public class Connection : IConnection
/// <summary>
/// Occurs when the <see cref="Connection"/> state changes.
/// </summary>
- public event Action<ConnectionState> StateChanged;
+ public event Action<StateChange> StateChanged;
/// <summary>
/// Initializes a new instance of the <see cref="Connection"/> class.
@@ -132,7 +132,7 @@ public Connection(string url, string queryString)
/// Gets the querystring specified in the ctor.
/// </summary>
public string QueryString { get; private set; }
-
+
/// <summary>
/// Gets the current <see cref="ConnectionState"/> of the connection.
/// </summary>
@@ -148,7 +148,7 @@ private set
{
if (StateChanged != null)
{
- StateChanged(value);
+ StateChanged(new StateChange(_state, value));
}
_state = value;
View
1  SignalR.Client/SignalR.Client.csproj
@@ -78,6 +78,7 @@
<Compile Include="ObservableConnection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Hubs\HubProxyExtensions.cs" />
+ <Compile Include="StateChange.cs" />
<Compile Include="Transports\AutoTransport.cs" />
<Compile Include="Transports\HttpBasedTransport.cs" />
<Compile Include="Transports\IClientTransport.cs" />
View
29 SignalR.Client/StateChange.cs
@@ -0,0 +1,29 @@
+namespace SignalR.Client
+{
+ /// <summary>
+ /// Represents a change in the connection state.
+ /// </summary>
+ public class StateChange
+ {
+ /// <summary>
+ /// Creates a new stance of <see cref="StateChange"/>.
+ /// </summary>
+ /// <param name="oldState">The old state of the connection.</param>
+ /// <param name="newState">The new state of the connection.</param>
+ public StateChange(ConnectionState oldState, ConnectionState newState)
+ {
+ OldState = oldState;
+ NewState = newState;
+ }
+
+ /// <summary>
+ /// Gets the old state of the connection.
+ /// </summary>
+ public ConnectionState OldState { get; private set; }
+
+ /// <summary>
+ /// Gets the new state of the connection.
+ /// </summary>
+ public ConnectionState NewState { get; private set; }
+ }
+}
View
4 samples/SignalR.Client.Samples/Program.cs
@@ -91,9 +91,9 @@ private static void RunStreamingSample()
Console.WriteLine("[{0}]: Connection restablished", DateTime.Now);
};
- connection.StateChanged += newState =>
+ connection.StateChanged += change =>
{
- Console.WriteLine("{0} => {1}", connection.State, newState);
+ Console.WriteLine("{0} => {1}", change.OldState, change.NewState);
};
connection.Error += e =>
Please sign in to comment.
Something went wrong with that request. Please try again.