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


C# IncomingMessage.IsCancelled方法代码示例

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


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

示例1: HandleConnectionData

        private void HandleConnectionData(ref byte[] data)
        {
            int pos = 0;
            while (pos < data.Length)
            {
                try
                {
                    if (data[0] == 60)
                    {
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> Policy Request");
                        SendData(PolicyReplyData);
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] <-- Policy Sent");
                        Close();
                        return;
                    }

                    // Total length of message (without this): 3 Base64 bytes
                    int messageLength = Base64Encoding.DecodeInt32(new[] {data[pos++], data[pos++], data[pos++]});

                    // ID of message: 2 Base64 bytes
                    uint messageID = Base64Encoding.DecodeUInt32(new[] {data[pos++], data[pos++]});

                    // Data of message: (messageLength - 2) bytes
                    byte[] content = new byte[messageLength - 2];
                    for (int i = 0; i < content.Length; i++)
                    {
                        content[i] = data[pos++];
                    }

                    // Create message object
                    IncomingMessage message = new IncomingMessage(messageID, content);

                    if (Habbo.IsLoggedIn())
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + Habbo.GetUsername() + "] --> " +
                                                                           message.GetHeader() +
                                                                           message.GetContentString());
                    else
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> " +
                                                                           message.GetHeader() +
                                                                           message.GetContentString());

                    // Handle message object
                    bool unknown = true;

                    if (_packetHandlers.GetLength(0) > messageID)
                    {
                        if (_packetHandlers[messageID, 3] != null)
                        {
                            lock (_packetHandlers[messageID, 3])
                            {
                                _packetHandlers[messageID, 3].Invoke(Habbo, message); // Execute High Priority
                                unknown = false;
                            }
                        }

                        if (message.IsCancelled())
                            return;

                        if (_packetHandlers[messageID, 2] != null)
                        {
                            lock (_packetHandlers[messageID, 2])
                            {
                                _packetHandlers[messageID, 2].Invoke(Habbo, message); // Execute Low Priority
                                unknown = false;
                            }
                        }

                        if (message.IsCancelled())
                            return;

                        if (_packetHandlers[messageID, 1] != null)
                        {
                            lock (_packetHandlers[messageID, 1])
                            {
                                _packetHandlers[messageID, 1].Invoke(Habbo, message); // Execute Default Action
                                unknown = false;
                            }
                        }

                        if (_packetHandlers[messageID, 0] != null)
                        {
                            lock (_packetHandlers[messageID, 0])
                            {
                                _packetHandlers[messageID, 0].Invoke(Habbo, message); // Execute Watchers
                                unknown = false;
                            }
                        }
                    }

                    if (unknown)
                    {
                        CoreManager.ServerCore.GetStandardOut().PrintWarning("Packet " + messageID + " ('" +
                                                                             message.GetHeader() + "') unhandled!");
                    }
                }
                catch (IndexOutOfRangeException) // Bad formatting!
                {
                    // TODO: Move this to IHI
                    //IonEnvironment.GetHabboHotel().GetClients().StopClient(_id, 0);
                }
//.........这里部分代码省略.........
开发者ID:habb0,项目名称:IHI,代码行数:101,代码来源:IonTcpConnection.cs


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