/// <summary> /// Handles operation SetViewDistance: Changes the subscribe and unsubscribe radius for an InterestArea. /// </summary> public OperationResponse OperationSetViewDistance(PeerBase peer, OperationRequest request) { var operation = new SetViewDistance(peer.Protocol, request); if (!operation.IsValid) { return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); InterestArea interestArea; if (this.TryGetInterestArea(operation.InterestAreaId, out interestArea) == false) { return(operation.GetOperationResponse((int)ReturnCode.InterestAreaNotFound, "InterestAreaNotFound")); } lock (interestArea.SyncRoot) { interestArea.ViewDistanceEnter = operation.ViewDistanceEnter; interestArea.ViewDistanceExit = operation.ViewDistanceExit; interestArea.UpdateInterestManagement(); } // don't send response return(null); }
public override OperationResponse Handle(MmoActor actor, OperationRequest request, SendParameters sendParameters) { var operation = new SetViewDistance(actor.Peer.Protocol, request); if (!operation.IsValid) { return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); InterestArea interestArea; if (actor.TryGetInterestArea(operation.InterestAreaId, out interestArea) == false) { return(operation.GetOperationResponse((int)ReturnCode.InterestAreaNotFound, "InterestAreaNotFound")); } lock (interestArea.SyncRoot) { interestArea.ViewDistanceEnter = operation.ViewDistanceEnter.ToVector(true); interestArea.ViewDistanceExit = operation.ViewDistanceExit.ToVector(true); interestArea.UpdateInterestManagement(); } log.InfoFormat("setted interest area min = {0} max = {1}", interestArea.ViewDistanceEnter, interestArea.ViewDistanceExit); // don't send response return(null); }