protected static GetPropertiesResponse CreateGetPropertiesResponse(OperationResponse response) { var result = new GetPropertiesResponse(); if (response.Parameters.ContainsKey(ParameterCode.PlayerProperties)) { result.ActorProperties = (Hashtable)response[ParameterCode.PlayerProperties]; } if (response.Parameters.ContainsKey(ParameterCode.GameProperties)) { result.GameProperties = (Hashtable)response[ParameterCode.GameProperties]; } return(result); }
protected virtual void HandleGetPropertiesOperation( PlayerPeer peer, GetPropertiesRequest getPropertiesRequest, SendParameters sendParameters) { var response = new GetPropertiesResponse(); // check if game properties should be returned if ((getPropertiesRequest.PropertyType & (byte)PropertyType.Game) == (byte)PropertyType.Game) { response.GameProperties = Properties.GetProperties(getPropertiesRequest.GamePropertyKeys); } // check if actor properties should be returned if ((getPropertiesRequest.PropertyType & (byte)PropertyType.Actor) == (byte)PropertyType.Actor) { response.ActorProperties = new Hashtable(); if (getPropertiesRequest.ActorNumbers == null) { foreach (var actor in Actors) { var actorProperties = actor.Properties.GetProperties(getPropertiesRequest.ActorPropertyKeys); response.ActorProperties.Add(actor.ActorNr, actorProperties); } } else { foreach (var actorNumber in getPropertiesRequest.ActorNumbers) { var actor = Actors.GetActorByNumber(actorNumber); if (actor != null) { var actorProperties = actor.Properties.GetProperties(getPropertiesRequest.ActorPropertyKeys); response.ActorProperties.Add(actorNumber, actorProperties); } } } } peer.SendOperationResponse( new OperationResponse(getPropertiesRequest.OperationRequest.OperationCode, response), sendParameters); }
/// <summary> /// Handles the <see cref = "GetPropertiesRequest" /> operation: Sends the properties with the <see cref = "OperationResponse" />. /// </summary> /// <param name = "peer"> /// The peer. /// </param> /// <param name = "getPropertiesRequest"> /// The operation to handle. /// </param> /// <param name = "sendParameters"> /// The send Parameters. /// </param> protected virtual void HandleGetPropertiesOperation(HivePeer peer, GetPropertiesRequest getPropertiesRequest, SendParameters sendParameters) { var response = new GetPropertiesResponse(); // check if game properties should be returned if ((getPropertiesRequest.PropertyType & (byte)PropertyType.Game) == (byte)PropertyType.Game) { response.GameProperties = this.Properties.GetProperties(getPropertiesRequest.GamePropertyKeys); } // check if actor properties should be returned if ((getPropertiesRequest.PropertyType & (byte)PropertyType.Actor) == (byte)PropertyType.Actor) { response.ActorProperties = new Hashtable(); if (getPropertiesRequest.ActorNumbers == null) { foreach (var actor in this.Actors) { this.AddActorPropertiesToResponse(getPropertiesRequest, actor, response); } } else { foreach (var actorNumber in getPropertiesRequest.ActorNumbers) { var actor = this.ActorsManager.ActorsGetActorByNumber(actorNumber); this.AddActorPropertiesToResponse(getPropertiesRequest, actor, response); } } } peer.SendOperationResponse(new OperationResponse(getPropertiesRequest.OperationRequest.OperationCode, response), sendParameters); }
private void AddActorPropertiesToResponse(GetPropertiesRequest getPropertiesRequest, Actor actor, GetPropertiesResponse response) { if (actor == null) { return; } var actorProperties = actor.Properties.GetProperties(getPropertiesRequest.ActorPropertyKeys); var addUserId = getPropertiesRequest.ActorPropertyKeys == null ? this.PublishUserId : getPropertiesRequest.ActorPropertyKeys.Contains(ActorParameter.UserId); if (addUserId) { actorProperties.Add((byte) ActorParameter.UserId, actor.UserId); } response.ActorProperties.Add(actor.ActorNr, actorProperties); }
private QueueResultViewModel GetQueueResultViewFrom(GetPropertiesResponse<MultipleFamilyViewModel> response) { return new QueueResultViewModel { Properties = response.ViewModels }; }