Esempio n. 1
0
        /// <summary>
        /// Constructs a <see cref="StarServer"/> instance
        /// </summary>
        /// <param name="config">The configuration for this <see cref="StarServer"/></param>
        /// <param name="proxyManager"></param>
        /// <param name="packetTypes">The packet types to be used by this server instance</param>
        /// <param name="packetHandlerTypes">The type of packet handlers to be used by this server instance</param>
        public StarServer(ServerConfiguration config, StarProxyManager proxyManager, Type[] packetTypes, Type[] packetHandlerTypes)
        {
            AddPacketTypes(packetTypes);

            Proxies      = proxyManager;
            ServerConfig = config;

            IPAddress bindAddress;
            IPAddress serverAddress;

            if (ServerConfig.BindAddress == "0.0.0.0")
            {
                bindAddress = IPAddress.Any;
            }
            else
            {
                bindAddress = IPAddress.Parse(ServerConfig.BindAddress);
            }

            if (ServerConfig.ServerBindAddress == "127.0.0.1")
            {
                serverAddress = IPAddress.Loopback;
            }
            else
            {
                serverAddress = IPAddress.Parse(ServerConfig.ServerBindAddress);
            }

            LocalEndPoint  = new IPEndPoint(bindAddress, ServerConfig.BindPort);
            ServerEndPoint = new IPEndPoint(serverAddress, ServerConfig.ServerBindPort);

            _packetHandlers = new Dictionary <Type, Func <IPacketHandler> >();
            AddPacketHandlers(packetHandlerTypes);

            SocketPool = new SocketAsyncEventArgsPool(config.MaxConnections * 2, config.MaxConnections * 4, 65536);

            _serverRunning = 0;
        }
Esempio n. 2
0
 /// <summary>
 /// Constructs a <see cref="StarServer"/> instance
 /// </summary>
 /// <param name="config">The configuration for this <see cref="StarServer"/></param>
 /// <param name="connManager"></param>
 public StarServer(ServerConfiguration config, StarProxyManager connManager)
     : this(config, connManager, Type.EmptyTypes)
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Constructs a <see cref="StarServer"/> instance
 /// </summary>
 /// <param name="config">The configuration for this <see cref="StarServer"/></param>
 /// <param name="proxyManager"></param>
 /// <param name="packetTypes">The packet types to be used by this server instance</param>
 public StarServer(ServerConfiguration config, StarProxyManager proxyManager, Type[] packetTypes)
     : this(config, proxyManager, packetTypes, Type.EmptyTypes)
 {
 }