コード例 #1
0
        public static void Main(string[] args)
        {
            ReceiveQueue.Start(PacketHandler.Handle);
            ServerSocket.Start(13338);
            Console.WriteLine($"Server running!");

            var t = new Thread(() =>
            {
                Console.WriteLine($"Heartbeat Thread started.");
                while (true)
                {
                    foreach (var kvp in Collections.Players)
                    {
                        var player = kvp.Value;

                        if (DateTime.Now >= player.LastPing.AddSeconds(1))
                        {
                            Console.WriteLine($"Sending Ping to {player.Name}/{player.Username}.");
                            player.Socket.Send(MsgPing.Create(player.UniqueId));
                            player.LastPing = DateTime.Now;
                        }
                    }

                    Thread.Sleep(1);
                }
            });

            t.Start();
            while (true)
            {
                Console.ReadLine();
            }
        }
コード例 #2
0
ファイル: Zephy.cs プロジェクト: Akadeax/Zephy
        static void Main()
        {
            #region Seeding
            SeederHandler.Seed(new SeederEntriesAmount
            {
                userSeederAmount    = 2,
                channelSeederAmount = 1,
                messageSeederAmount = 50,
            });
            #endregion

            #region Socket
            // Start UDP Broadcast Receiver that answers Clients search for the server's local IP
            broadcastReceiver.StartReceive();

            // Start TCP Server
            serverSocket.Start();

            Logger.Information("Listening to new connections...");

            while (true)
            {
                string cmd = Console.ReadLine();
                if (cmd == "clear")
                {
                    Console.Clear();
                }
                else if (cmd == "q")
                {
                    break;
                }
            }
            #endregion
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Alumniminium/Chat
        public static void Main()
        {
            FConsole.Title = "SERVER APP";
            GlobalExceptionHandler.Setup();
            Jit.PreJit();

            Core.Db = new JsonDb();
            Core.Db.EnsureDbReady();

            ReceiveQueue.OnPacket += PacketRouter.Route;

            ServerSocket.Start(Core.Settings.Port);

            FConsole.WriteLine("Online");

            while (true)
            {
                var cmd = FConsole.ReadLine();
                switch (cmd)
                {
                case "exit":
                    Core.Db.Save();
                    Environment.Exit(0);
                    break;

                default:
                    break;
                }
            }
        }
コード例 #4
0
 private Protocol(int port)
 {
     _builds           = new Dictionary <int, CodeBuild>();
     _socket           = new ServerSocket(port);
     _socket.Closed   += this.OnClosed;
     _socket.Accepted += this.OnAccepted;
     _socket.Error    += this.OnError;
     _socket.Receive  += this.OnReceive;
     _socket.Start();
 }
コード例 #5
0
        public void Start()
        {
            ServerSocket.Start();

            DisplayColoredText("Сервер запущен!", ConsoleColor.White);
            while (true)
            {
                TcpClient client = ServerSocket.AcceptTcpClient();
                GetAndParseUserData(client); //начинаем читать пользователя чтобы узнать что он хочет, авторизоватся или зарегистрироватся
            }
        }
コード例 #6
0
ファイル: ServerMode.cs プロジェクト: Twi1ightSpark1e/AOKGlab
        public static bool Start(Form owner)
        {
            string result = server.Start(owner);

            if (result != null)
            {
                MessageBox.Show(result);
                return(false);
            }
            return(true);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: Alumniminium/AlumniStorage
        static void Main()
        {
            GlobalExceptionHandler.Setup();
            FConsole.WriteLine("Hello World!");
            ServerSocket.OnPacket += PacketRouter.Handle;
            ServerSocket.Start(65533);

            while (true)
            {
                Console.ReadLine();
            }
        }
コード例 #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //   Hide();
            // ShowIcon = false;
            // ShowInTaskbar = false;
            // FormBorderStyle = FormBorderStyle.None;
            StopWatch.Start();
            Console.Title = "TheArcaneChat Server -=- v1.0.0";

            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();

            ServerSocket.Start();
            Log(" >> Server Started");
            //Visible = false;
            new Thread(() =>
            {
                //serverSocket.Server.Listen(1000);
                while (true)
                {
                    try
                    {
                        while (!ServerSocket.Pending())
                        {
                            Thread.Sleep(5);
                        }

                        ClientSocket = ServerSocket.AcceptTcpClient();
                        //Log($" >> Client No: {_counter++} started!");
                        Clients.Add(ClientSocket);
                        new HandleClient(this).StartClient(ClientSocket, _counter);
                        _counter++;
                        new Task(() =>
                        {
                            new SoundPlayer(@"C:\Windows\Media\Speech On.wav").Play();
                        }).Start();
                        this.Invoke(new MethodInvoker(() => { ConnectionCount.Text = $"Connected clients: {Clients.Count}"; }));
                    }
                    catch (Exception exception)
                    {
                        //Log(exception);
                    }
                }
            }).Start();
        }
コード例 #9
0
        static void Main(string[] args)
        {
            ClientFacade clientFacade = new ClientFacade();

            ServerFacade serverFacade = new ServerFacade(clientFacade);

            IServerController serverController = new ServerController(serverFacade);

            IServer server = new ServerSocket(serverController);

            serverFacade.Init(serverController);
            clientFacade.Init(serverController);

            Task.Run(() => server.Start());

            while (Console.ReadLine().ToLower() != "stop")
            {
                ;
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: Alumniminium/PixelGlue
        public static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                BotCount = int.Parse(args[0]);
            }

            ReceiveQueue.Start(PacketHandler.Handle);
            ServerSocket.Start(13338);
            Console.WriteLine("Server running!");

            World.Systems.Add(new GCMonitor(true, false));
            World.Systems.Add(new MoveSystem(true, false));

            for (int i = 0; i < BotCount; i++)
            {
                ref var npc = ref World.CreateEntity(100_000 + i);
                npc.Add(new NetworkComponent(100_000 + i));
                npc.Add <PositionComponent>();
                npc.Add <DestinationComponent>();
                npc.Add(new SpeedComponent(16));
                npc.Add <VelocityComponent>();
                Collections.Npcs.TryAdd(100_000 + i, new Npc(100_000 + i));
            }