Skip to content

Commit

Permalink
fix bug timeroutcallback transportOptions null point
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchenliang committed Dec 11, 2012
1 parent 988fc6f commit d78b257
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 26 deletions.
7 changes: 4 additions & 3 deletions SimpleClient/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ private void setFilterBt_Click(object sender, RoutedEventArgs e)
ja.Add("[email protected]");
valueArray.SetValues(ja);
filter.SetInValue(valueArray);

Debug.WriteLine("\n-- set filer --");
Debug.WriteLine(filter);
Debug.WriteLine("---------------\n");

//Remove the filter.
//HCondition filter = new HCondition(JObject.Parse("{}"));
Expand Down Expand Up @@ -237,8 +241,5 @@ private void clearBt_Message_Click(object sender, RoutedEventArgs e)
Update_TextBlock_UI(msgScreen, "clear");
}




}
}
5 changes: 2 additions & 3 deletions SimpleClient/SimpleClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\MyGit\socketio_w8\SocketIO4Net\packages\Newtonsoft.Json.4.5.10\lib\winrt45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\libs\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
Expand Down
3 changes: 3 additions & 0 deletions SimpleClient/SimpleClient.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<UseSimulator>True</UseSimulator>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<UseSimulator>True</UseSimulator>
</PropertyGroup>
</Project>
Binary file modified hubiquitus4w8.v11.suo
Binary file not shown.
22 changes: 8 additions & 14 deletions hubiquitus4w8/hapi/client/HClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class HClient

public string FullJid { get { return this.transportOptions.Jid.GetFullJID() ; } }
public string Resource { get { return this.transportOptions.GetResource() ; } }
public ConnectionStatus Status { get { return this.connectionStatus; } }

public delegate void StatusEventHandler(HStatus status);
public delegate void MessageEventHandler(HMessage message);
Expand Down Expand Up @@ -108,7 +109,6 @@ public void Connect(string publisher, string password, HOptions options)

if (shouldConnect)
{
notifyStatus(ConnectionStatus.CONNECTING, ConnectionErrors.NO_ERROR, null);
try
{
fillTransportOptions(publisher, password, options);
Expand All @@ -133,6 +133,7 @@ public void Connect(string publisher, string password, HOptions options)
this.transportManager.onData = transport_onData;
isEventHandlerAdded = true;
}
notifyStatus(ConnectionStatus.CONNECTING, ConnectionErrors.NO_ERROR, null);
this.transportManager.Connect(this.transportOptions);
}
}
Expand Down Expand Up @@ -187,10 +188,7 @@ public void Disconnect()
notifyStatus(ConnectionStatus.DISCONNECTED, ConnectionErrors.NOT_CONNECTED, null);
}

public ConnectionStatus Status()
{
return this.connectionStatus;
}



/// <summary>
Expand Down Expand Up @@ -225,8 +223,11 @@ public void Send(HMessage message, Action<HMessage> messageDelegate)
{
message.SetMsgid(Guid.NewGuid().ToString());
messageDelegates.Add(message.GetMsgid(), messageDelegate);

ThreadPoolTimer timeOutTimer = ThreadPoolTimer.CreateTimer(TimeroutCallback, new TimeSpan(0,0,0,0,message.GetTimeout()));

ThreadPoolTimer timeOutTimer = ThreadPoolTimer.CreateTimer((obj) =>
{
notifyResultError(message.GetMsgid(), ResultStatus.EXEC_TIMEOUT, "The response of message is time out.", null);
}, new TimeSpan(0, 0, 0, 0, 2/*message.GetTimeout()*/));

timerOutDictionary.Add(message.GetMsgid(), timeOutTimer);
}
Expand All @@ -239,13 +240,6 @@ public void Send(HMessage message, Action<HMessage> messageDelegate)
transportManager.SendObject(message);
}

private void TimeroutCallback(object stateInfo)
{
HMessage message = (HMessage)stateInfo;
notifyResultError(message.GetMsgid(), ResultStatus.EXEC_TIMEOUT, "The response of message is time out.", null);
messageDelegates.Remove(message.GetMsgid());
}

/// <summary>
/// The client MUST be connected to access to this service.
/// Demands the server a subscription to a channel.
Expand Down
1 change: 1 addition & 0 deletions hubiquitus4w8/hapi/hStructures/HOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public void SetMsgTimeout(int timeout)
else
this["msgTimeout"] = 30000; //30000s by default
}

catch (Exception e)
{
Debug.WriteLine("{0} : Can not update the msgTimerout attribute", e.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void socketIO_Error(object sender, ErrorEventArgs e)
string errorMsg = null;
if (e != null)
{
errorMsg = e.Message;
errorMsg = e.ErrorStatus.ToString();
}
if (connTimeoutTimer != null)
{
Expand Down
11 changes: 6 additions & 5 deletions hubiquitus4w8/hubiquitus4w8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\MyGit\socketio_w8\SocketIO4Net\packages\Newtonsoft.Json.4.5.10\lib\winrt45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\..\libs\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SocketIO4Net, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\libs\SocketIO4Net.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\socketio_w8\SocketIO4Net\SocketIO4Net\SocketIO4Net.csproj">
<Project>{27d619fb-a7c1-4366-9b12-283a702d0778}</Project>
<Name>SocketIO4Net</Name>
</ProjectReference>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>
Expand Down
Binary file removed libs/SocketIO4Net.dll
Binary file not shown.

0 comments on commit d78b257

Please sign in to comment.