public OperationResponse GetOperationResponse(short errorCode, string debugMessage) { var responseObject = new RadarSubscribeResponse { WorldName = this.WorldName }; return(new OperationResponse(this.OperationRequest.OperationCode, responseObject) { ReturnCode = errorCode, DebugMessage = debugMessage }); }
/// <summary> /// Expects operation RadarSubscribe and subscribes the peer to the Radar. /// Publishes an OperationResponse with error code ReturnCode.Ok if successful. /// </summary> public static OperationResponse OperationRadarSubscribe(PeerBase peer, OperationRequest request, SendParameters sendParameters) { var mmoPeer = (MmoPeer)peer; var operation = new RadarSubscribe(peer.Protocol, request); if (!operation.IsValid) { return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }; } if (mmoPeer.RadarSubscription != null) { mmoPeer.RadarSubscription.Dispose(); mmoPeer.RadarSubscription = null; } World world; if (WorldCache.Instance.TryGet(operation.WorldName, out world) == false) { return operation.GetOperationResponse((int)ReturnCode.WorldNotFound, "WorldNotFound"); } mmoPeer.RadarSubscription = world.Radar.Channel.Subscribe(mmoPeer.RequestFiber, m => RadarChannel_OnItemEventMessage(peer, m)); // set return values var responseObject = new RadarSubscribeResponse { BoundingBox = world.Area, TileDimensions = world.TileDimensions, WorldName = world.Name }; // send response before sending radar content var response = new OperationResponse(request.OperationCode, responseObject); peer.SendOperationResponse(response, sendParameters); // send complete radar content to client world.Radar.SendContentToPeer(mmoPeer); // response already sent return null; }
/// <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 responseObject = new RadarSubscribeResponse { WorldName = this.WorldName }; return new OperationResponse(this.OperationRequest.OperationCode, responseObject) { ReturnCode = errorCode, DebugMessage = debugMessage }; }