Esempio n. 1
0
 protected DataContract(IRpcProtocol protocol, IDictionary <byte, object> dataMembers)
 {
     if (dataMembers != null)
     {
         this.isValid = ObjectDataMemberMapper.TrySetValues <DataMemberAttribute>(this, dataMembers, new ObjectDataMemberMapper.TryConvertDelegate <DataMemberAttribute>(protocol.TryConvertParameter), out this.missingParams, out this.invalidParams);
     }
     else
     {
         this.isValid = true;
     }
     this.errorMessage = this.BuildErrorMessage(dataMembers);
 }
        /// <summary>
        /// Sends a(n) <see cref="GameEvent"/> to a session
        /// </summary>
        public void SendEvent(int sessionId, GameEvent gameEvent, MessageParameters messageParameters)
        {
            var parameters = ObjectDataMemberMapper.GetValues <DataMemberAttribute>(gameEvent);

            parameters.Add(0, sessionId);

            var eventData = new EventData(gameEvent.EventCode, parameters);

            this.SendEvent(eventData, new SendParameters
            {
                ChannelId = messageParameters.ChannelId,
                Encrypted = messageParameters.Encrypted,
            });
        }
        /// <summary>
        /// Sends a(n) <see cref="GameOperationResponse"/> to a session
        /// </summary>
        public void SendOperationResponse(int sessionId, GameOperationResponse gameResponse, MessageParameters messageParameters)
        {
            var parameters = ObjectDataMemberMapper.GetValues <DataMemberAttribute>(gameResponse);

            parameters.Add(0, sessionId);

            var operationResponse = new OperationResponse(gameResponse.OperationCode, parameters)
            {
                ReturnCode   = gameResponse.ReturnCode,
                DebugMessage = gameResponse.DebugMessage
            };

            this.SendOperationResponse(operationResponse,
                                       new SendParameters
            {
                ChannelId = messageParameters.ChannelId,
                Encrypted = messageParameters.Encrypted,
            });
        }
Esempio n. 4
0
 /// <summary>
 /// Converts properties of an object to <see cref="P:Photon.SocketServer.OperationRequest.Parameters"/>.
 ///  Included properties require the <see cref="T:Photon.SocketServer.Rpc.DataMemberAttribute"/>.
 /// </summary>
 /// <param name="dataContract">
 /// The properties of this object are mapped to <see
 /// cref="P:Photon.SocketServer.OperationRequest.Parameters"/>.
 /// </param>
 public void SetParameters(object dataContract)
 {
     this.Parameters = (dataContract == null) ? null : ObjectDataMemberMapper.GetValues <DataMemberAttribute>(dataContract);
 }
Esempio n. 5
0
 public Dictionary <byte, object> ToDictionary()
 {
     return(ObjectDataMemberMapper.GetValues <DataMemberAttribute>(this));
 }