// services ============================================================= private void SessListenNotice(ServiceRequest request, ref ServiceResponse response) { JObject jo = JObject.Parse((string)request.data); System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { var msg = jo["data"]; string sessid = (string)msg["sessid"]; string type = (string)msg["type"]; string laddress = ((string)msg["localip"]).Split(':')[0]; int lport = Int32.Parse(((string)msg["localip"]).Split(':')[1]); string raddress = ((string)msg["remoteip"]).Split(':')[0]; int rport = Int32.Parse(((string)msg["remoteip"]).Split(':')[1]); string tick = (string)msg["tick"]; string conntime = (string)msg["conntime"]; ListenUnit server = new ListenUnit() { ID = sessid, IpAddress = laddress, Port = lport, }; uidata.ListenTable.Add(server); })); }
private void SessDetailResponse(ServiceRequest request, ref ServiceResponse response) { JObject jo = JObject.Parse((string)request.data); if ((int)jo["errcode"] != 0) { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) .Info((string)jo["id"] + ": " + (string)jo["errmsg"]); return; } System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { uidata.ListenTable.Clear(); uidata.AcceptTable.Clear(); foreach (var item in jo["data"]) { string sessid = (string)item["sessid"]; string type = (string)item["type"]; string laddress = ((string)item["localip"]).Split(':')[0]; int lport = Convert.ToInt32(((string)item["localip"]).Split(':')[1]); string raddress = ((string)item["remoteip"]).Split(':')[0]; int rport = Convert.ToInt32(((string)item["remoteip"]).Split(':')[1]); string tick = (string)item["tick"]; string conntime = (string)item["conntime"]; string ccid = (string)item["ccid"]; string name = (string)item["name"]; bool admin = Convert.ToBoolean((string)item["admin"]); if (type == "SockSessServer") { ListenUnit server = new ListenUnit() { ID = sessid, IpAddress = laddress, Port = lport, Name = name, }; if (serverport == server.Port) { server.Name = "EnvServer"; } uidata.ListenTable.Add(server); } if (type == "SockSess") { AcceptUnit client = new AcceptUnit() { ID = sessid, LocalEP = new IPEndPoint(IPAddress.Parse(laddress), lport), RemoteEP = new IPEndPoint(IPAddress.Parse(raddress), rport), TickTime = DateTime.Parse(tick), ConnTime = DateTime.Parse(conntime), CCID = ccid, Name = name, Admin = admin, }; uidata.AcceptTable.Add(client); } } })); }