Exemplo n.º 1
0
        private static void Process()
        {
            var stopWatch = new Stopwatch();

            while (Active)
            {
                stopWatch.Restart();

                // Send a hearth beat message to all clients inside all channels.
                foreach (var channel in Channels.All())
                {
                    foreach (var client in channel.Clients())
                    {
                        client.Send(KeepaliveBuilder.Build(client));
                    }
                }

                stopWatch.Stop();

                // Keep the thread in sync with the internal.
                var sleepTime = Internal - (int)stopWatch.ElapsedMilliseconds;
                if (sleepTime > 0)
                {
                    Thread.Sleep(sleepTime);
                }
                else
                {
                    Console.WriteLine("Hearthbeat couldn't keep-up!!");
                }
            }
        }
Exemplo n.º 2
0
        protected override bool Process(GameClient sender, JoinServerMessageClient message)
        {
            // NOTE We should not use the user id in any 'public' packets so we'll just send 0 instead and use the username & token to authenticate.
            Console.WriteLine("Join Server for Username: {0}, Token: {1}", message.Username, message.Token);

            sender.AddFlag(GameSessionFlags.Authenticated);

            sender.Send(JoinServerResponseBuilder.Build(sender));
            sender.Send(KeepaliveBuilder.Build(sender));

            return(true);
        }