public static HttpExtend.HttpHeader GetResponse(IProperties properties) { HttpExtend.HttpHeader command = new HttpExtend.HttpHeader(); command.Properties = properties.ToHeaders(); return command; }
public static HttpExtend.HttpHeader Get(string appName, IProperties properties) { HttpExtend.HttpHeader command = new HttpExtend.HttpHeader(); command.Action = COMMAND_GET + " " + appName; command.Properties = properties.ToHeaders(); return command; }
public static HttpExtend.HttpHeader GetResponse(IProperties properties) { HttpExtend.HttpHeader command = new HttpExtend.HttpHeader(); command.Properties = properties.ToHeaders(); return(command); }
public static HttpExtend.HttpHeader Get(string appName, IProperties properties) { HttpExtend.HttpHeader command = new HttpExtend.HttpHeader(); command.Action = COMMAND_GET + " " + appName; command.Properties = properties.ToHeaders(); return(command); }
protected override void OnMessageReceive(PacketRecieveMessagerArgs e) { base.OnMessageReceive(e); if (e.Message is HttpExtend.HttpHeader) { HttpExtend.HttpHeader header = e.Message as HttpExtend.HttpHeader; if (header.Connection != null) { e.Channel["keep-alive"] = true; } header = new HttpHeader(); header.Action = "HTTP/1.1 200 OK"; header["Cache-Control"] = "private"; header.ContentType = "text/html; charset=utf-8"; header.Server = "Beetle/HttpExtend"; header.Connection = "keep-alive"; // FileReader reader = new FileReader("h:\\KendeSoft.htm"); // header.Length = reader.FileInfo.Length; HttpBody body = HttpPacket.InstanceBodyData(); body.Data.Encoding("<p>beetle http extend server!</p><p>Beetle是基于c#编写的高性能稳定的TCP通讯组件,它可以轻易支持成千上万长连接基础上进行密集的通讯交互. 组件提供了出色的性能支持和可靠的稳定性足以保证应用7x24无间断运行。为了更好地利用.Net的网络IO来处理数据,组件提供智能合并消息机制,组件调度器会根据当前负载情况对发向客户的多个消息进行合并处处理,从而减少IO操作达到更高的处理效能;通过测试在大量用户信息广播的情况轻易可以处理上百万的消息转发</p>", Encoding.UTF8); body.Eof = true; header.Length = body.Data.Count; e.Channel.Send(header); e.Channel.Send(body); //while (reader.Read()) //{ // HttpBody body = HttpPacket.InstanceBodyData(); // reader.ReadTo(body); // e.Channel.Send(body); //} } }
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); } }
public AppHost GetHost(IProperties properties = null) { if (properties == null) { properties = new Properties(); } HttpExtend.HttpHeader request = Protocol.Get(mAppName, properties); HttpExtend.HttpHeader result = mNode.Send <HttpExtend.HttpHeader>(request); if (result.RequestType == "500") { throw new Exception(result.ActionDetail); } return(new AppHost { Host = result["Host"], Port = int.Parse(result["Port"]) }); }