Example #1
0
        public static long GetStatistics(string statType)
        {
            switch (statType)
            {
            case "Ping":
                return((long)PingMs);

            case "SentBytes":
                return(NetworkMain.ClientConnection.Statistics.SentBytes);

            case "ReceivedBytes":
                return(NetworkMain.ClientConnection.Statistics.ReceivedBytes);

            case "Latency":
                return((long)NetworkMain.ClientConnection.ServerConnection.AverageRoundtripTime);

            case "TimeOffset":
                return(TimeOffset);

            case "LastSendTime":
                return((long)(LunaNetworkTime.UtcNow - LastSendTime).TotalMilliseconds);

            case "LastReceiveTime":
                return((long)(LunaNetworkTime.UtcNow - LastReceiveTime).TotalMilliseconds);

            case "MessagesInCache":
                return(MessageStore.GetMessageCount(null));

            case "MessageDataInCache":
                return(MessageStore.GetMessageDataCount(null));
            }
            return(0);
        }
Example #2
0
        public void TestMsgMessageStore()
        {
            var msg1 = Factory.CreateNew <VesselSrvMsg, VesselPositionMsgData>();

            Assert.AreEqual(0, MessageStore.GetMessageCount(typeof(VesselSrvMsg)));
            Assert.AreEqual(0, MessageStore.GetMessageDataCount(typeof(VesselPositionMsgData)));

            var msg2 = Factory.CreateNew <VesselSrvMsg, VesselPositionMsgData>();

            Assert.AreEqual(0, MessageStore.GetMessageCount(typeof(VesselSrvMsg)));
            Assert.AreEqual(0, MessageStore.GetMessageDataCount(typeof(VesselPositionMsgData)));

            //Set first message as "used"
            msg1.Recycle();

            Assert.AreEqual(1, MessageStore.GetMessageCount(typeof(VesselSrvMsg)));
            Assert.AreEqual(1, MessageStore.GetMessageDataCount(typeof(VesselPositionMsgData)));

            //If we retrieve a new message the first one should be reused
            var msg3 = Factory.CreateNew <VesselSrvMsg, VesselPositionMsgData>();

            msg2.Recycle();
            msg3.Recycle();

            Assert.AreEqual(2, MessageStore.GetMessageCount(typeof(VesselSrvMsg)));
            Assert.AreEqual(2, MessageStore.GetMessageDataCount(typeof(VesselPositionMsgData)));

            var msg4 = Factory.CreateNew <VesselSrvMsg, VesselPositionMsgData>();

            Assert.AreEqual(1, MessageStore.GetMessageCount(typeof(VesselSrvMsg)));
            Assert.AreEqual(1, MessageStore.GetMessageDataCount(typeof(VesselPositionMsgData)));
        }