Ejemplo n.º 1
0
        public override void DoHandle(INetworkChannel channel, PlayerEntity entity,
                                      EClient2ServerMessage eClient2ServerMessage,
                                      PingRequestMessage messageBody)
        {
            var serverStatus = _contexts.session.serverSessionObjects.FpsSatatus;
            var request      = messageBody;
            var resp         = Protobuf.PingMessage.Allocate();

            resp.Id                 = request.Id;
            resp.Type               = request.Type;
            resp.Time               = request.Time;
            resp.AvgDelta           = (int)(serverStatus.AvgDelta);
            resp.MaxDelta           = (int)(serverStatus.MaxDelta);
            resp.CmdLose            = 100;
            resp.CmdTotal           = 100;
            resp.Fps5               = serverStatus.Fps5;
            resp.Fps30              = serverStatus.Fps30;
            resp.Fps60              = serverStatus.Fps60;
            resp.GcCount            = System.GC.CollectionCount(0);
            resp.GcStatus           = SingletonManager.Get <gc_manager>().d_gc_disabled;
            resp.AllocatedMb        = (int)SingletonManager.Get <gc_manager>().allocated_mb;
            resp.AllocationRateMbps = (int)SingletonManager.Get <gc_manager>().average_allocation_rate_mbps;
            if (request.Type)
            {
                channel.SendReliable((int)EServer2ClientMessage.Ping, resp);
            }
            else
            {
                channel.SendRealTime((int)EServer2ClientMessage.Ping, resp);
            }

            resp.ReleaseReference();
        }
 public void Setup()
 {
     m_Message = new PingRequestMessage
     {
         Request = DateTime.Now
     };
 }
Ejemplo n.º 3
0
 public void Execute(GameClient <TPlayer> model, PingRequestMessage message)
 {
     if (model.localPlayer != null)
     {
         model.localPlayer.lastReceivedPingRequest = TimeUtils.CurrentTime();
     }
     model.Send(new PongRequestMessage(message.pingRequestId), Channel.unreliable);
 }
Ejemplo n.º 4
0
        public void PingRequestHandlerSendsReplyTest()
        {
            var request = new PingRequestMessage();

            m_Service.PingRequestHandler(request);

            m_Bus.Received()
            .PublishAsync(Arg.Is <PingResponseMessage>(x => x.Request == request.Request));
        }
Ejemplo n.º 5
0
        private void UdpMsg(INetworkChannel channel)
        {
            var ping = PingRequestMessage.Allocate();

            ping.Id   = _seq;
            ping.Type = false;
            ping.Time = DateTime.UtcNow.ToMillisecondsSinceEpoch();
            channel.SendRealTime((int)EClient2ServerMessage.Ping, ping);
            ping.ReleaseReference();
        }
Ejemplo n.º 6
0
        private void TcpMsg(INetworkChannel channel)
        {
            var ping = PingRequestMessage.Allocate();

            ping.Id   = _seq;
            ping.Type = true;
            ping.Time = DateTime.UtcNow.ToMillisecondsSinceEpoch();
            ;
            channel.SendReliable((int)EClient2ServerMessage.Ping, ping);
        }
Ejemplo n.º 7
0
        internal void PingRequestHandler([NotNull] PingRequestMessage message)
        {
            var reply = new PingResponseMessage
            {
                ServiceName = m_Name,
                Request     = message.Request
            };

            Bus.PublishAsync(reply);
        }
Ejemplo n.º 8
0
        internal override MqttMessage Decode(byte[] message)
        {
            PingRequestMessage ping = new PingRequestMessage();
            int  index       = 0;
            byte fixedHeader = message[index];

            DecodeFixedHeader(fixedHeader);

            int remainingLength = DecodeRemainingLength(message);

            if (remainingLength != 0)
            {
            }

            return(ping);
        }
        /// <summary>
        /// Processes the specified command.
        /// </summary>
        /// <param name="command">
        /// The command to process.
        /// </param>
        /// <param name="mediator">
        /// A processing intermediary that is used to process sub-commands. Do not process <paramref name="command" /> using
        /// <paramref name="mediator" />, as doing so will generally result in infinite-looping.
        /// </param>
        /// <param name="controlToken">
        /// A token that ensures thread safety for the operation.
        /// </param>
        protected override void Process(HeartbeatMessage command, ICommandMediator mediator, ConcurrencyControlToken controlToken)
        {
            var pingRequest  = new PingRequestMessage();
            var pingResponse = (PingResponseMessage)null;
            var stopwatch    = Stopwatch.StartNew();

            pingResponse = mediator.Process <PingResponseMessage>(pingRequest);
            stopwatch.Stop();

            if (pingResponse is null == false && pingResponse.RequestMessageIdentifier == pingRequest.Identifier)
            {
                Console.WriteLine($"Success! The round trip ping operation completed in {stopwatch.ElapsedMilliseconds} milliseconds.");
                return;
            }

            Console.WriteLine("The round trip ping operation failed.");
        }