Beispiel #1
0
        protected override void _constructor_handled()
        {
            _buffer_writer = new MessageBufferWriter(false);
            _handler       = new MessageHandler <ServerHandlerAttribute>();

            _rcv_action += OnReceive;
            _reader      = new BigEndianReader();

            if (_client.IsRunning)
            {
                // send protocolRequired
                using (BigEndianWriter _writer = _buffer_writer.Build((ushort)_protocol_required.protocolID, null, new MessageDataBufferWriter(_protocol_required).Parse(_protocol_required_message)))
                {
                    _client_sender.Handle(_client, _writer.Data);
                    logger.Info($"[{_tag}] {_protocol_required.BasicString}");
                }
                // send helloGameMessage
                using (BigEndianWriter _writer = _buffer_writer.Build((ushort)_hello_game.protocolID, null, new MessageDataBufferWriter(_hello_game).Parse(_hello_game_message_content)))
                {
                    _client_sender.Handle(_client, _writer.Data);
                    logger.Info($"[{_tag}] {_hello_game.BasicString}");
                }
                // send rdm only for client check
                if (_raw_data_bytes.Length > 0)
                {
                    using (BigEndianWriter _writer = _buffer_writer.Build(8892, null, new MessageDataBufferWriter(_raw_data_message).Parse(_raw_data_content)))
                    {
                        _client_sender.Handle(_client, _writer.Data);
                        logger.Info($"[{_tag}] {_raw_data_message.BasicString}");
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void Send(bool fromClient, ClientEntity sender, NetworkElement element, NetworkContentElement content, uint?instance_id = null)
        {
            if (fromClient && instance_id is null)
            {
                throw new ArgumentNullException(nameof(instance_id));
            }

            byte[] _data       = new MessageDataBufferWriter(element).Parse(content);
            byte[] _final_data = new MessageBufferWriter(fromClient).Build((ushort)(element.protocolID == 6253 ? 8892 /*rdm*/ : element.protocolID), instance_id, _data).Data;

            _callback._client_sender.Handle(sender, _final_data);

            logger.Info($"fake message sent : {element.BasicString} {(instance_id.HasValue ? instance_id.Value : 0)}");
        }