예제 #1
0
        private void OnGetInfo(Beetle.IChannel channel, string appname, IProperties properties)
        {
            HttpHeader  result;
            TrackerInfo info;

            byte[]             data;
            BytesReader        reader;
            HttpBody           body;
            IAppTrackerHandler appHandler = GetAppHandler(appname);

            if (appHandler == null)
            {
                result        = new HttpHeader();
                result.Action = "500 " + string.Format("{0} Tracker Handler Notfound", appname);
                channel.Send(result);
            }
            else
            {
                info          = appHandler.GetInfo(properties);
                data          = Encoding.UTF8.GetBytes(info.Data);
                result        = new HttpHeader();
                result.Action = "200";
                result.Length = data.Length;
                result[Protocol.HEADER_INFOTYPE] = info.TypeName;
                channel.Send(result);
                reader = new BytesReader(data, 0, data.Length);
                while (reader.Read())
                {
                    body = HttpPacket.InstanceBodyData();
                    reader.ReadTo(body);
                    channel.Send(body);
                }
            }
        }
예제 #2
0
 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);
         //}
     }
 }