Exemple #1
0
        /// <summary>
        /// Fetch Equipments
        /// </summary>
        /// <param name="peer">Mmo Peer</param>
        /// <param name="request">Operation Request</param>
        /// <returns>Operation Response</returns>
        public OperationResponse OperationFetchEquipments(PeerBase peer, OperationRequest request)
        {
            var operation = new FetchInventory(peer.Protocol, request);

            if (operation.IsValid)
            {
                try
                {
                    Equipments equipments = DbManager.Instance.FetchEquipments(operation.UserId);

                    FetchEquipmentsResponse response = new FetchEquipmentsResponse()
                    {
                        Equipments = Equipments.Serialize(equipments)
                    };

                    if (equipments != null)
                    {
                        return new OperationResponse(request.OperationCode, response) { ReturnCode = (int)ReturnCode.Ok, DebugMessage = "OK" };
                    }
                }
                catch (Exception ex)
                {
                    log.Fatal("FetchInventory: " + ex.ToString());
                }

                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.Fatal, DebugMessage = "Can't FetchInventory()" };
            }
            else
            {
                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperation, DebugMessage = operation.GetErrorMessage() };
            }
        }
        /// <summary>
        /// Gets the operation response.
        /// </summary>
        /// <param name="errorCode">
        /// The error code.
        /// </param>
        /// <param name="debugMessage">
        /// The debug message.
        /// </param>
        /// <returns>
        /// A new operation response.
        /// </returns>
        public OperationResponse GetOperationResponse(short errorCode, string debugMessage)
        {
            var responseObjcet = new FetchEquipmentsResponse();

            return new OperationResponse(this.OperationRequest.OperationCode, responseObjcet) { ReturnCode = errorCode, DebugMessage = debugMessage };
        }