private void ConnectAndUpdateServerList() { DispatchHandler.Instance.AddHandler <ServersMsg>(ProcessServersMsg); DispatchHandler.Instance.AddHandler <InterChatCommandMsg>(ProcessInterChatCommandMsg); try { #if DEBUG _session.Connect("127.0.0.1", Configuration.PylonPort); #else _session.Connect(Configuration.PylonHost, Configuration.PylonPort); #endif _session.StartReceive(); _session.Send(new RequestServerMsg()); UpdateUi(() => timerRefresh.Enabled = true); } catch (Exception exception) { UpdateUi(() => { ShowError("Cannot connect to xelina: {0}", exception.Message); textAccountName.Enabled = false; listViewServers.Enabled = false; buttonInterChat.Enabled = false; buttonStartGame.Enabled = false; }); } }
private void Reconnect() { try { _session = MessageSessionManager.Instance.CreateSession(); #if DEBUG _session.Connect("127.0.0.1", Configuration.PylonPort); #else _session.Connect(Configuration.PylonHost, Configuration.PylonPort); #endif _session.StartReceive(); _session.Send(new InterChatLoginMsg { Name = _userName }); return; } catch { Task.Delay(5000).ContinueWith(_ => Reconnect()); } }