static void Main(string[] args)
        {
            Server server = null;

            try
            {
#if USE_APP_CONFIG
                server = new Server();
#else
                ServerConfiguration cfg = new ServerConfiguration();
                cfg.Host = "0.0.0.0";//bind address
                cfg.TlsConfiguration.Enabled = false;

                Dictionary <ushort, ProtocolConfiguration> protocolConfigurations =
                    new Dictionary <ushort, ProtocolConfiguration>();

                protocolConfigurations.Add(KeepAliveProtocol.PROTOCOL_IDENTIFIER,
                                           new ProtocolConfiguration(KeepAliveProtocol.PROTOCOL_IDENTIFIER, typeof(KeepAliveProtocol)));

                WinAuthProtocolConfigurationServer winAuthCfg = new WinAuthProtocolConfigurationServer();
                winAuthCfg.AddRole("Administrators");
                winAuthCfg.AddUser("TestUser");
                winAuthCfg.DMeraGeneralUserIdentifier = "Rea Mera";
                protocolConfigurations.Add(WinAuthProtocol.PROTOCOL_IDENTIFIER, winAuthCfg);

                protocolConfigurations.Add(HelloProtocol.PROTOCOL_IDENTIFIER,
                                           new ProtocolConfiguration(HelloProtocol.PROTOCOL_IDENTIFIER, typeof(HelloProtocolServer)));

                server = new Server(cfg, protocolConfigurations);
                //server.Logger.LogPackets = true;
                server.Logger.LogToDebuggerOutputView = true;
                server.Logger.LogDebug = true;
#endif
                server.Logger.Log(Level.Info, "Press any key to quit.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.ReadKey();
                if (server != null)
                {
                    server.Close();
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Server server = null;

            try
            {
                ServerConfiguration cfg = new ServerConfiguration();
                //cfg.TlsConfiguration.Enabled = true;
                //cfg.TlsConfiguration.Certificate = "yourserver.com";

                Dictionary <ushort, ProtocolConfiguration> protocolConfigurations =
                    new Dictionary <ushort, ProtocolConfiguration>();

                protocolConfigurations.Add(KeepAliveProtocol.PROTOCOL_IDENTIFIER,
                                           new ProtocolConfiguration(KeepAliveProtocol.PROTOCOL_IDENTIFIER, typeof(KeepAliveProtocol)));

                WinAuthProtocolConfigurationServer winAuthCfg = new WinAuthProtocolConfigurationServer();
                winAuthCfg.AddRole("Administrators");
                winAuthCfg.AddUser("TestUser");
                protocolConfigurations.Add(WinAuthProtocol.PROTOCOL_IDENTIFIER, winAuthCfg);

                protocolConfigurations.Add(HelloProtocol.PROTOCOL_IDENTIFIER,
                                           new ProtocolConfiguration(HelloProtocol.PROTOCOL_IDENTIFIER, typeof(HelloProtocolServer)));

                server = new Server(cfg, protocolConfigurations);
                server.Logger.Log(Level.Info, "Press any key to quit.");
                Console.ReadKey();

                server.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.ReadKey();
                if (server != null)
                {
                    server.Close();
                }
            }
        }