Exemple #1
0
        private void OnGet(Beetle.IChannel channel, string appname, IProperties properties)
        {
            IAppTrackerHandler appHandler = GetAppHandler(appname);

            if (appHandler == null)
            {
                HttpHeader result = new HttpHeader();
                result.Action = "500 " + string.Format("{0} Tracker Handler Notfound", appname);
                channel.Send(result);
            }
            else
            {
                AppHost apphost = appHandler.GetHost(properties);
                if (apphost == null)
                {
                    HttpHeader result = new HttpHeader();
                    result.Action = "500 App Host Notfound!";
                    channel.Send(result);
                }
                else
                {
                    HttpHeader result = new HttpHeader();
                    result.Action  = "200";
                    result["Host"] = apphost.Host;
                    result["Port"] = apphost.Port.ToString();
                    channel.Send(result);
                }
            }
        }
Exemple #2
0
        private IAppTrackerHandler GetAppHandler(string name)
        {
            IAppTrackerHandler result = null;

            mHandlers.TryGetValue(name, out result);
            return(result);
        }
Exemple #3
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);
                }
            }
        }