diff --git a/pomelo-dotnetClient/pomelo-dotnetClient.csproj b/pomelo-dotnetClient/pomelo-dotnetClient.csproj
index f6c9bd4..acb23b4 100755
--- a/pomelo-dotnetClient/pomelo-dotnetClient.csproj
+++ b/pomelo-dotnetClient/pomelo-dotnetClient.csproj
@@ -14,7 +14,7 @@
true
full
false
- bin\Debug
+ ..\dist\
DEBUG;
prompt
4
diff --git a/pomelo-dotnetClient/src/client/PomeloClient.cs b/pomelo-dotnetClient/src/client/PomeloClient.cs
index 3b10495..873cce1 100644
--- a/pomelo-dotnetClient/src/client/PomeloClient.cs
+++ b/pomelo-dotnetClient/src/client/PomeloClient.cs
@@ -39,7 +39,7 @@ public class PomeloClient : IDisposable
public event Action NetWorkStateChangedEvent;
- private NetWorkState netWorkState = NetWorkState.CLOSED; //current network state
+ public NetWorkState netWorkState {get; private set;} //current network state
private EventManager eventManager;
private Socket socket;
@@ -48,10 +48,15 @@ public class PomeloClient : IDisposable
private uint reqId = 1;
private ManualResetEvent timeoutEvent = new ManualResetEvent(false);
+
private int timeoutMSec = 8000; //connect timeout count in millisecond
- public PomeloClient()
+ private bool _keepWaitWhenConnect = true;
+
+ public PomeloClient(bool keepWaitWhenConnect = true)
{
+ _keepWaitWhenConnect = keepWaitWhenConnect;
+ netWorkState = NetWorkState.CLOSED;
}
///
@@ -70,15 +75,20 @@ public void initClient(string host, int port, Action callback = null)
try
{
- IPAddress[] addresses = Dns.GetHostEntry(host).AddressList;
- foreach (var item in addresses)
+ if (!IPAddress.TryParse(host, out ipAddress))
{
- if (item.AddressFamily == AddressFamily.InterNetwork)
+ var addresses = Dns.GetHostEntry(host).AddressList;
+
+ foreach (var item in addresses)
{
- ipAddress = item;
- break;
+ if (item.AddressFamily == AddressFamily.InterNetwork)
+ {
+ ipAddress = item;
+ break;
+ }
}
}
+
}
catch (Exception e)
{
@@ -121,7 +131,7 @@ public void initClient(string host, int port, Action callback = null)
}
}), this.socket);
- if (timeoutEvent.WaitOne(timeoutMSec, false))
+ if (_keepWaitWhenConnect && timeoutEvent.WaitOne(timeoutMSec, false))
{
if (netWorkState != NetWorkState.CONNECTED && netWorkState != NetWorkState.ERROR)
{
diff --git a/pomelo-dotnetClient/src/protobuf/MsgDecoder.cs b/pomelo-dotnetClient/src/protobuf/MsgDecoder.cs
index 18a7b47..8d4e93f 100755
--- a/pomelo-dotnetClient/src/protobuf/MsgDecoder.cs
+++ b/pomelo-dotnetClient/src/protobuf/MsgDecoder.cs
@@ -93,12 +93,12 @@ private JsonObject decodeMsg(JsonObject msg, JsonObject proto, int length)
object _name;
if (!msg.TryGetValue(name.ToString(), out _name))
{
- msg.Add(name.ToString(), new List