Esempio n. 1
0
        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");
                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();
            }
        }
Esempio n. 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();
            }
        }
 /// <summary>
 /// Calls the base <see cref="US.OpenServer.Protocols.ProtocolBase.Initialize"/>
 /// function then saves a reference to the Session and WinAuthProtocolConfigurationServer.
 /// </summary>
 /// <param name="session">A SessionBase that encapsulates the connection
 /// session. This value is casted to Session.</param>
 ///<param name="pc">A ProtocolConfiguration that contains configuration
 /// properties. This value is casted to WinAuthProtocolConfigurationServer.</param>
 /// <param name="userData">An object that may be used by client applications to
 /// pass objects or data to client side protocol implementations. This parameter is
 /// not used.</param>
 public override void Initialize(SessionBase session, ProtocolConfiguration pc, object userData = null)
 {
     base.Initialize(session, pc, userData);
     this.sessionEx = (Session)session;
     this.pc        = pc as WinAuthProtocolConfigurationServer;
 }
 /// <summary>
 /// Calls the base <see cref="US.OpenServer.Protocols.ProtocolBase.Initialize"/>
 /// function then saves a reference to the Session and WinAuthProtocolConfigurationServer.
 /// </summary>
 /// <param name="session">A SessionBase that encapsulates the connection
 /// session. This value is casted to Session.</param>
 ///<param name="pc">A ProtocolConfiguration that contains configuration
 /// properties. This value is casted to WinAuthProtocolConfigurationServer.</param>
 /// <param name="userData">An object that may be used by client applications to
 /// pass objects or data to client side protocol implementations. This parameter is
 /// not used.</param>
 public override void Initialize(SessionBase session, ProtocolConfiguration pc, object userData = null)
 {
     base.Initialize(session, pc, userData);
     this.sessionEx = (Session)session;
     this.pc = pc as WinAuthProtocolConfigurationServer;
 }