public static new Packet FromNetBuffer(NetIncomingMessage incomingMessage)
        {
            object o = null;
            var locked = incomingMessage.ReadBoolean();
            var type = (ContentType) incomingMessage.ReadByte();

            if (!locked)
            {
                var length = incomingMessage.ReadInt32();
                var bytes = incomingMessage.ReadBytes(length);

                o = SerializationHelper.ByteArrayToObject(bytes);
            }

            var packet = new ContentResultPacket(o, locked, type);

            return packet;
        }
        private void Handler(ContentResultPacket contentResultPacket)
        {
            if (contentResultPacket.Locked)
            {
                ShowMessageBox("The server rejected your request for this content. This usually happens because someone else has it checked out.", "Server Response");
                return;
            }

            var page = GetActiveContentPage();

            // Clear all bindings first
            var contentGrid = tabContentPages.SelectedTab.Controls[0];
            BindingHelper.ClearBindings(contentGrid);

            page.BoundObject = contentResultPacket.ContentObject as IContentTemplate;
            page.BindTemplateObject(contentResultPacket.ContentObject);

            openedID = (contentResultPacket.ContentObject as IContentTemplate).Id;
        }
        private void Handler(ContentRequestPacket contentRequestPacket)
        {
            var type = contentRequestPacket.ContentType;
            object o = null;
            var locked = !_contentLockManager.TryAcquireLock(contentRequestPacket.Sender, contentRequestPacket.ID,
                                                            contentRequestPacket.ContentType);

            if (!locked)
            {

                switch (type)
                {
                    case ContentType.Item:
                        o = GetItemByID(contentRequestPacket.ID);
                        break;
                    case ContentType.Skill:
                        o = GetSkillByID(contentRequestPacket.ID);
                        break;
                    case ContentType.Map:
                        o = GetMapByID(contentRequestPacket.ID);
                        break;
                    default:
                        Logger.Instance.Log(Level.Warn,
                                            "The client has requested a resource with an unknown identifier.");
                        return;
                }
            }

            var packet = new ContentResultPacket(o, locked, contentRequestPacket.ContentType);
            ClientNetworkManager.Instance.SendPacket(packet, contentRequestPacket.Sender);
        }