当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequest.Dispose方法代码示例

本文整理汇总了C#中MiniHttpd.HttpRequest.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest.Dispose方法的具体用法?C# HttpRequest.Dispose怎么用?C# HttpRequest.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MiniHttpd.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnFileRequested

        public void OnFileRequested(HttpRequest request, IDirectory directory)
        {
            //request.Response.SetHeader("Content-Type", "text/plain; charset=utf-8");
            request.Response.ResponseContent = new MemoryStream();
            StreamWriter textwriter = new StreamWriter(request.Response.ResponseContent);
            GridClient client;
            AvatarTracker avatars;
            Events events;
            StreamReader reader = new StreamReader(request.PostData);
            string qstring = reader.ReadToEnd();
            reader.Dispose();
            Dictionary<string,string> POST = deviMobile.PostDecode(qstring);
            // Pull out the session.
            if (!POST.ContainsKey("sid"))
            {
                textwriter.WriteLine("Need an SID.");
                textwriter.Flush();
                return;
            }
            Guid guid = new Guid(POST["sid"]);
            User user = new User();
            lock (this.users)
            {
                if (!this.users.ContainsKey(guid))
                {
                    textwriter.WriteLine("Error: invalid SID");
                    textwriter.Flush();
                    return;
                }
                user = this.users[guid];
                client = user.Client;
                avatars = user.Avatars;
                events = user.Events;
                user.LastRequest = DateTime.Now;
            }
            // Get the message type.
            string messagetype = POST["MT"];

            // Check that the message is signed if it should be.
            if (Array.IndexOf(REQUIRED_SIGNATURES, messagetype) > -1)
            {
                if (!VerifySignature(user, qstring))
                {
                    textwriter.WriteLine("ERROR: Received hash and expected hash do not match.");
                    textwriter.Flush();
                    return;
                }
            }

            // Right. This file is fun. It takes information in POST paramaters and sends them to
            // the server in the appropriate format. Some will return data immediately, some will return
            // keys to data that will arrive in the message queue, some return nothing but you get
            // something in the message queue later, and some return nother ever.
            //
            // The joys of dealing with multiple bizarre message types.

            switch (messagetype)
            {
                case "chat":
                    client.Self.Chat(POST["msg"], int.Parse(POST["chan"]), (ChatType)((byte)int.Parse(POST["type"])));
                    break;
                case "im":
                    if (POST.ContainsKey("id")) {
                        client.Self.InstantMessage(new UUID(POST["to"]), POST["msg"], new UUID(POST["id"]));
                    } else {
                        client.Self.InstantMessage(new UUID(POST["to"]), POST["msg"]);
                    }
                    break;
                case "avatarlist":
                    {
                        List<Hashtable> list = new List<Hashtable>();
                        foreach (KeyValuePair<uint, Avatar> pair in avatars.Avatars)
                        {
                            Avatar avatar = pair.Value;
                            Hashtable hash = new Hashtable();
                            hash.Add("name", avatar.Name);
                            hash.Add("id", avatar.ID);
                            //hash.Add("LocalID", avatar.LocalID);
                            //hash.Add("Position", avatar.Position);
                            //hash.Add("Rotation", avatar.Rotation);
                            //hash.Add("Scale", avatar.Scale);
                            //hash.Add("GroupName", avatar.GroupName);
                            list.Add(hash);
                        }
                        textwriter.Write(MakeJson.FromObject(list));
                    }
                    break;
                case "friends_count":
                    {
                        Hashtable Total = new Hashtable();
                        Total.Add("t", client.Friends.FriendList.Count);
                        textwriter.Write(MakeJson.FromHashtable(Total));
                    }
                    break;
                case "friends":
                    {
                        InternalDictionary<UUID, FriendInfo> friends = client.Friends.FriendList;
                        List<Hashtable> friendlist = new List<Hashtable>();

                        int added = 0; int total = 0;
//.........这里部分代码省略.........
开发者ID:jor3l,项目名称:j2me-client,代码行数:101,代码来源:SendMessage.cs


注:本文中的MiniHttpd.HttpRequest.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。