Example #1
0
        static void Main(string[] args)
        {
            m_Handler = new ConsoleEventDelegate(ConsoleEventCallback);
            SetConsoleCtrlHandler(m_Handler, true);

            ClusterServer = new ClusterServer();
            Console.ReadLine();
            ClusterServer.Dispose();
        }
Example #2
0
        private void StartSlowServer(int count = 1)
        {
            for (var i = 0; i < count; i++)
            {
                var serverOptions = new ServerOptions {
                    Async = true, MethodDuration = 1000000, MethodName = "some_method", Port = GetFreePort()
                };
                var server = new ClusterServer(serverOptions, log);
                clusterServers.Add(server);

                server.Start();
            }
        }
Example #3
0
        private void StartRegularServer(int count = 1)
        {
            for (var i = 0; i < count; i++)
            {
                var serverOptions = new ServerOptions {
                    Async = true, MethodDuration = 10, MethodName = "some_method", Port = GetFreePort()
                };
                var server = new ClusterServer(serverOptions, log);
                clusterServers.Add(server);

                Console.WriteLine($"Started server at port {serverOptions.Port}");

                server.Start();
            }
        }
Example #4
0
        /// <summary>
        /// Gives the client an ID and asks the Master Server if the current username belongs to them.
        /// </summary>
        /// <param name="server">The Cluster Server to run this on.</param>
        /// <param name="toClient">The client's new ID.</param>
        /// <param name="username">The client's username to validate.</param>
        internal static void InitializeLogin(this ClusterServer server, int toClient, string username)
        {
            /**
             * TODO:
             * 1. There's no API decided currently. But, when the time comes, the user should authenticate through that.
             * 2. For now, just receive a username and let them use that name. No real validation needs to take place yet.
             * 3. Think about making it flexible enough to allow users to import their own auth systems.
             */
            using (Packet packet = new Packet((int)ServerPackets.initializeLogin))
            {
                packet.Write(username);
                packet.Write(toClient);

                server.SendTcpData(toClient, packet);
            }
        }
Example #5
0
        protected ClusterServer CreateServer(int delay, bool notStart = false)
        {
            var serverOptions = new ServerOptions
            {
                Async = true, MethodDuration = delay, MethodName = "some_method",
                Port  = GetFreePort()
            };

            var server = new ClusterServer(serverOptions, this.log);

            this.clusterServers.Add(server);

            if (!notStart)
            {
                server.Start();
                Console.WriteLine($"Started server at port {serverOptions.Port}");
            }

            return(server);
        }
Example #6
0
 public static void Main(string[] args)
 {
     using (var server = new ClusterServer())
         server.Start();
 }
Example #7
0
 /// <summary>
 /// Creates a new cluster InterConnector instance.
 /// </summary>
 /// <param name="server">Parent cluster server</param>
 public InterConnector(ClusterServer server)
 {
     this.clusterServer = server;
 }