/// <summary> /// Handles operation <see cref = "SetProperties" />: Sets the <see cref = "Item.Properties" /> of an <see cref = "Item" /> and ultimately sends event <see cref = "ItemPropertiesSet" /> to other clients. /// </summary> /// <param name = "peer"> /// The client peer. /// </param> /// <param name = "request"> /// The request. /// </param> /// <param name = "sendParameters"> /// The send Parameters. /// </param> /// <returns> /// Null or an <see cref = "OperationResponse" /> with error code <see cref = "ReturnCode.ItemNotFound" />. /// </returns> public OperationResponse OperationSetProperties(PeerBase peer, OperationRequest request, SendParameters sendParameters) { var operation = new SetProperties(peer.Protocol, request); if (!operation.IsValid) { return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }; } operation.OnStart(); Item item; if (false == operation.ItemType.HasValue || string.IsNullOrEmpty(operation.ItemId)) { item = this.Avatar; // set return values operation.ItemId = item.Id; operation.ItemType = item.Type; } else if (this.TryGetItem(operation.ItemType.Value, operation.ItemId, out item) == false) { return operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound"); } return this.ItemOperationSetProperties(item, operation, sendParameters); }
/// <summary> /// Handles operation SetProperties: Sets the Item.Properties of an Item and ultimately sends event ItemPropertiesSet to other clients. /// </summary> public OperationResponse OperationSetProperties(PeerBase peer, OperationRequest request, SendParameters sendParameters) { var operation = new SetProperties(peer.Protocol, request); if (!operation.IsValid) { return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); Item item; if (string.IsNullOrEmpty(operation.ItemId)) { item = this.Avatar; // set return values operation.ItemId = item.Id; } else if (this.TryGetItem(operation.ItemId, out item) == false) { return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound")); } return(this.ItemOperationSetProperties(item, operation, sendParameters)); }
public override OperationResponse Handle(MmoActor actor, OperationRequest request, SendParameters sendParameters) { var operation = new SetProperties(actor.Peer.Protocol, request); if (!operation.IsValid) { return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); Item item; if (false == operation.ItemType.HasValue || string.IsNullOrEmpty(operation.ItemId)) { item = actor.Avatar; // set return values operation.ItemId = item.Id; operation.ItemType = item.Type; } else if (actor.TryGetItem(operation.ItemType.Value, operation.ItemId, out item) == false) { return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound")); } return(this.ItemOperationSetProperties(item, operation, sendParameters, actor)); }