internal override IFreeformEntity ParseBufferInternal(ref IFreeformEntity entity, IFreeformEntity rootEntity, int id, byte[] buffer)
        {
            if (buffer.Length == 1)
            {
                return new FFTgt_G2H_GameMessage_ResponseAckNack()
                {
                    Status = buffer[0].GetAppId<FF_GmuId_GameMessage_ResponseTypes, FF_AppId_GameMessage_ResponseTypes>(),
                };
            }
            else if (buffer.Length >= 3)
            {
                FF_AppId_GameMessage_ProtocolTypes protocolType = buffer[0].GetAppId<FF_GmuId_GameMessage_ProtocolTypes, FF_AppId_GameMessage_ProtocolTypes>();
                FF_AppId_GameMessage_GameResponses responseType = buffer[1].GetAppId<FF_GmuId_GameMessage_GameResponses, FF_AppId_GameMessage_GameResponses>();

                if (responseType == FF_AppId_GameMessage_GameResponses.Ignore)
                {
                    return new FFTgt_G2H_GameMessage_MessageNotSent()
                    {
                        ProtocolType = protocolType,
                        IsGameResponseExpected = responseType,
                        MessageData = new byte[] { 0 },
                    };
                }
                else
                {
                    if (buffer[2] == 0)
                    {
                        return new FFTgt_G2H_GameMessage_MessageResponseTimeout()
                        {
                            ProtocolType = protocolType,
                            IsGameResponseExpected = responseType,
                            MessageData = new byte[] { 0 },
                        };
                    }
                    else if (protocolType == FF_AppId_GameMessage_ProtocolTypes.SAS)
                    {
                        int longPollCommand = (int)buffer[2];
                        if (_createCommands.ContainsKey(longPollCommand))
                        {
                            byte[] messageData = null;
                            if (buffer.Length > 3)
                                messageData = buffer.CopyToBuffer(3, buffer.Length - 3);
                            var target = _createCommands[longPollCommand]();
                            target.IsGameResponseExpected = responseType;
                            target.FromRawData(messageData);
                            return target;
                        }
                        else
                        {
                            var target = new FFTgt_G2H_GameMessage_SASCommand()
                            {
                                ProtocolType = protocolType,
                                IsGameResponseExpected = responseType,
                                LongPollCommand = buffer[2],
                            };
                            if (buffer.Length > 3)
                            {
                                target.MessageData = buffer.CopyToBuffer(3, buffer.Length - 3);
                            }
                            return target;
                        }
                    }
                }
            }
            return null;
        }
Exemple #2
0
        internal override IFreeformEntity ParseBufferInternal(ref IFreeformEntity entity, IFreeformEntity rootEntity, int id, byte[] buffer)
        {
            if (buffer.Length == 1)
            {
                return(new FFTgt_G2H_GameMessage_ResponseAckNack()
                {
                    Status = buffer[0].GetAppId <FF_GmuId_GameMessage_ResponseTypes, FF_AppId_GameMessage_ResponseTypes>(),
                });
            }
            else if (buffer.Length >= 3)
            {
                FF_AppId_GameMessage_ProtocolTypes protocolType = buffer[0].GetAppId <FF_GmuId_GameMessage_ProtocolTypes, FF_AppId_GameMessage_ProtocolTypes>();
                FF_AppId_GameMessage_GameResponses responseType = buffer[1].GetAppId <FF_GmuId_GameMessage_GameResponses, FF_AppId_GameMessage_GameResponses>();

                if (responseType == FF_AppId_GameMessage_GameResponses.Ignore)
                {
                    return(new FFTgt_G2H_GameMessage_MessageNotSent()
                    {
                        ProtocolType = protocolType,
                        IsGameResponseExpected = responseType,
                        MessageData = new byte[] { 0 },
                    });
                }
                else
                {
                    if (buffer[2] == 0)
                    {
                        return(new FFTgt_G2H_GameMessage_MessageResponseTimeout()
                        {
                            ProtocolType = protocolType,
                            IsGameResponseExpected = responseType,
                            MessageData = new byte[] { 0 },
                        });
                    }
                    else if (protocolType == FF_AppId_GameMessage_ProtocolTypes.SAS)
                    {
                        int longPollCommand = (int)buffer[2];
                        if (_createCommands.ContainsKey(longPollCommand))
                        {
                            byte[] messageData = null;
                            if (buffer.Length > 3)
                            {
                                messageData = buffer.CopyToBuffer(3, buffer.Length - 3);
                            }
                            var target = _createCommands[longPollCommand]();
                            target.IsGameResponseExpected = responseType;
                            target.FromRawData(messageData);
                            return(target);
                        }
                        else
                        {
                            var target = new FFTgt_G2H_GameMessage_SASCommand()
                            {
                                ProtocolType           = protocolType,
                                IsGameResponseExpected = responseType,
                                LongPollCommand        = buffer[2],
                            };
                            if (buffer.Length > 3)
                            {
                                target.MessageData = buffer.CopyToBuffer(3, buffer.Length - 3);
                            }
                            return(target);
                        }
                    }
                }
            }
            return(null);
        }