private void LoadInfo(IProperties properties) { foreach (TrackerHost item in mHosts) { try { if (item.Client.Available) { using (Beetle.Clients.SyncNode.Connection connection = item.Client.Pop()) { HttpExtend.HttpHeader command = Protocol.GetInfo(mAppName, properties); HttpExtend.HttpHeader result = connection.Send <HttpExtend.HttpHeader>(command); if (result.RequestType == "200" && result.Length > 0) { System.IO.Stream stream = ResultStream; stream.SetLength(0); stream.Position = 0; using (HttpExtend.HttpBody body = connection.Channel.Receive <HttpExtend.HttpBody>()) { stream.Write(body.Data.Array, 0, body.Data.Count); if (body.Eof) { stream.Position = 0; System.IO.StreamReader reader = new System.IO.StreamReader(stream, Encoding.UTF8); string type = result[Protocol.HEADER_INFOTYPE]; TrackerInfo = Formater.FromString(Type.GetType(type), reader.ReadToEnd()); return; } } } else { if (result.RequestType == "500") { Utils.Error <AppToTracker <T, P> >("{2} Get Track {0} info 500 error {1}", item.IPAddress, result.ActionDetail, mAppName); } } } } } catch (Exception e__) { Utils.Error <AppToTracker <T, P> >(e__, "{2} Get Track {0} info Error {1}", item.IPAddress, e__.Message, mAppName); } } }
private void OnTarck(object state) { mTimer.Change(-1, 0); try { P properties = new P(); properties.FromHeaders(Properties); if (Register != null) { Register(this, new EventRegisterArgs { AppToTracker = this, Properties = properties }); } foreach (TrackerHost item in mHosts) { try { if (item.Client.Available) { using (Beetle.Clients.SyncNode.Connection connection = item.Client.Pop()) { HttpExtend.HttpHeader command = Protocol.Register(mAppName, properties); HttpExtend.HttpHeader result = connection.Send <HttpExtend.HttpHeader>(command); if (result.RequestType != "200") { Utils.Error <AppToTracker <T, P> >("Register Track {0} Error {1}", item.IPAddress, result.ActionDetail); } } } } catch (Exception e__) { Utils.Error <AppToTracker <T, P> >(e__, " Track {0} Error {1}", item.IPAddress, e__.Message); } } LoadInfo(properties); } catch (Exception e_) { Utils.Error <AppToTracker <T, P> >(e_, " Track Error {0}", e_.Message); } finally { mTimer.Change(10, mTrackTime); } }