Ejemplo n.º 1
0
        private void ClientTreatment_OnMessageParsed(NetworkElement arg1, ProtocolJsonContent arg2)
        {
            var hooker = HookManager <T> .Instance[LocalClient.localIp.Port];

            if (hooker is null)
            {
                logger.Error("no proxy found");
                return;
            }

            if (ClientTreatment.Informations is MessageBuffer informations)
            {
                hooker.Proxy.LAST_GLOBAL_INSTANCE_ID = informations.InstanceId;
            }

            uint instance_id = hooker.Proxy.LAST_GLOBAL_INSTANCE_ID + hooker.Proxy.FAKE_MESSAGE_SENT;
            StartupConfiguration configuration = Configurations.ConfigurationManager.Instance.Startup;

            if (configuration.show_message)
            {
                logger.Info($"[client {RemoteClient.remoteIp}] {arg1.BasicString()}");
                if (configuration.show_message_content)
                {
                    logger.Info($"{arg2}");
                }
            }

            HandlerManager.Instance.Handle(arg1.protocolID, LocalClient, RemoteClient, arg2);
            RemoteClient.Send(ClientTreatment.Informations.ReWriteInstanceId(instance_id));
        }
Ejemplo n.º 2
0
        public void Send(NetworkElement message, ProtocolJsonContent content, bool clientSide)
        {
            if (message is null)
            {
                return;
            }

            using (BigEndianWriter writer = new BigEndianWriter())
            {
                byte[] data = ProtocolTreatmentExtension.FromContent(content, message);

                int cmpLen = _cmpLen(data.Length);
                writer.WriteShort((short)((message.protocolID << 2) | cmpLen));

                if (clientSide)
                {
                    writer.WriteUnsignedInt(GetCustomInstanceId());
                }

                switch (cmpLen)
                {
                case 0:
                    break;

                case 1:
                    writer.WriteByte((byte)data.Length);
                    break;

                case 2:
                    writer.WriteShort((short)data.Length);
                    break;

                case 3:
                    writer.WriteByte((byte)((data.Length >> 16) & 255));
                    writer.WriteShort((short)(data.Length & 65535));
                    break;
                }

                writer.WriteBytes(data);
                Send(writer.Data);

                OnCustomMessageSent?.Invoke(message, content);

                StartupConfiguration configuration = Configurations.ConfigurationManager.Instance.Startup;
                if (configuration.show_fake_message)
                {
                    logger.Info($"fake message sent to {remoteIp} |{message.BasicString()}]");
                    if (configuration.show_fake_message_content)
                    {
                        logger.Info($"{content}");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void ServerTreatment_OnMessageParsed(NetworkElement arg1, ProtocolJsonContent arg2)
        {
            StartupConfiguration configuration = Configurations.ConfigurationManager.Instance.Startup;

            if (configuration.show_message)
            {
                logger.Info($"[server {RemoteClient.remoteIp}] {arg1.BasicString()}");
                if (configuration.show_message_content)
                {
                    logger.Info($"{arg2}");
                }
            }

            HandlerManager.Instance.Handle(arg1.protocolID, LocalClient, RemoteClient, arg2);
        }