示例#1
0
        private void decode_Response(PhotonCmdHeader cmd_hdr, BinaryReader packet)
        {
            // see func ReliableMessage() decode in...
            // https://github.com/broderickhyman/photon_spectator/blob/master/photon_command.go

            var opResponse = new ReliableMessage_Response();

            opResponse.ChannelID = cmd_hdr.ChannelID;

            opResponse.OperationCode         = packet.ReadByte();   // Operation Code
            opResponse.OperationResponseCode = packet.ReadUInt16(); // Operation Response Code
            opResponse.OperationDebugByte    = packet.ReadByte();   // Operation Debug Byte

            opResponse.ParameterCount = packet.ReadInt16();         // Parameter Count   (?? is this valid for all msg types?)

            Event_Photon_Cmd_Info?.Invoke("Photon Reliable Response - " + opResponse.OperationResponseCode);

            var parameters = new ReliableMessage_Response.Paramaters();

            // decode the paramaters
            for (int i = 0; i < opResponse.ParameterCount; i++)
            {
                var             paramID   = packet.ReadByte();                  // paramID
                PhotonParamType paramType = (PhotonParamType)packet.ReadByte(); // paramType

                var param_value = Decode_PhotonValueType.Decode(packet, paramType);

                parameters[paramID] = param_value;
                Event_Photon_Info?.Invoke("ParamID: " + paramID + "  value: " + param_value.ToString());
            }
            opResponse.ParamaterData = parameters;

            Event_Photon_ReliableResponse?.Invoke(opResponse);
        }
示例#2
0
        private string RenderParameters(ReliableMessage_Response.Paramaters parms)
        {
            var acc = new List <string>();

            parms.ToList().ForEach(kvp =>
                                   acc.Add(RenderParameter(kvp.Key, kvp.Value)));

            return("PhotonParms - \n... " + String.Join("\n... ", acc));
        }