예제 #1
0
        public override void Update()
        {
            this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime);

            this.Recv();

            this.TimerOut();

            foreach (long id in updateChannels)
            {
                KChannel kChannel = this.GetKChannel(id);
                if (kChannel == null)
                {
                    continue;
                }
                if (kChannel.Id == 0)
                {
                    continue;
                }
                kChannel.Update();
            }
            this.updateChannels.Clear();

            while (this.removedChannels.Count > 0)
            {
                long     id = this.removedChannels.Dequeue();
                KChannel channel;
                if (!this.localConnChannels.TryGetValue(id, out channel))
                {
                    continue;
                }
                this.localConnChannels.Remove(id);
                channel.Dispose();
            }
        }
예제 #2
0
        public KService()
        {
            this.StartTime = TimeHelper.ClientNow();
            this.TimeNow   = (uint)(TimeHelper.ClientNow() - this.StartTime);
            this.socket    = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            //this.socket.Blocking = false;
            this.socket.Bind(new IPEndPoint(IPAddress.Any, 0));

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                const uint IOC_IN            = 0x80000000;
                const uint IOC_VENDOR        = 0x18000000;
                uint       SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
                this.socket.IOControl((int)SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null);
            }

            Instance = this;
        }
예제 #3
0
		public static async Task Send(this BenchmarkComponent self, Session session, int j)
		{
			try
			{
				//await session.Call(new C2R_Ping());
				++self.k;

				if (self.k % 100000 != 0)
				{
					return;
				}

				long time2 = TimeHelper.ClientNow();
				long time = time2 - self.time1;
				self.time1 = time2;
				Log.Info($"Benchmark k: {self.k} 每10W次耗时: {time} ms {session.Network.Count}");
			}
			catch (Exception e)
			{
				Log.Error(e);
			}
		}