コード例 #1
0
 public ServerCore(IMessageHandler messageHandler, ServerConnectionInfo connectionInfo, ILogger logger, IServerEventHandler eventHandler = null)
 {
     gameInfo            = new Server_GameInfo();
     clientManager       = new Server_ClientManager(this);
     this.connectionInfo = connectionInfo;
     this.messageHandler = messageHandler;
     connection          = new Server_Connection(clientManager, connectionInfo);
     messageReciever     = new Server_MessageReciever(connection, messageHandler);
     messageSender       = new Server_MessageSender(clientManager, logger);
     this.eventHandler   = eventHandler == null ? eventHandler = new ServerCoreShellHandler() : this.eventHandler = eventHandler;
 }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataProcessor"></param>
        public TcpServerService(IServerEventHandler eventHandler, ServerConfig serverConfig,
                                ILoggerFactory loggerFactory, Func <IDataProcessor> createDataProcessorFunc)
        {
            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <TcpServerService>();
            _serverConfig  = serverConfig;
            _eventHandler  = eventHandler;

            // define data processor
            _createDataProcessorFunc = createDataProcessorFunc;
        }
コード例 #3
0
        public TcpServerService(IServerEventHandler eventHandler, ServerConfig serverConfig,
                                ILoggerFactory loggerFactory, EnumDataProcessorType dataProcessorType,
                                Func <byte[], byte[]> getIdFunc = null)
        {
            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <TcpServerService>();
            _serverConfig  = serverConfig;
            _eventHandler  = eventHandler;

            // define data processor
            _createDataProcessorFunc = CreateDataProcesorFunc(serverConfig, loggerFactory, dataProcessorType, getIdFunc);
        }
コード例 #4
0
ファイル: Server.cs プロジェクト: proalex/BSUIR-DIPLOMA
        public Server(string host, int port, IClientEventHandler clientHandler, IServerEventHandler severHandler)
        {
            _port          = port;
            _host          = host;          // ?? throw new NullReferenceException("host is null");
            _clientHandler = clientHandler; // ?? throw new NullReferenceException("clientHandler is null");
            _severHandler  = severHandler;
            IPAddress ipv4Addresses = Array.Find(
                Dns.GetHostEntry(string.Empty).AddressList,
                a => a.AddressFamily == AddressFamily.InterNetwork);
            IPHostEntry ipHostInfo = Dns.GetHostEntry(host);

            _localEndPoint = new IPEndPoint(ipv4Addresses, port);
            _listener      = new Socket(AddressFamily.InterNetwork,
                                        SocketType.Stream, ProtocolType.Tcp);
        }
コード例 #5
0
        public Server(ServerConfiguration configuration, IServerEventHandler serverEventHandler)
        {
            LocalEndpoint = GetEndpoint(configuration.LocalHost, configuration.LocalPort);
            RemoteEndpoint = GetEndpoint(configuration.RemoteHost, configuration.RemotePort);

            ServerCertificate = new X509Certificate(configuration.CertificatePath, "");

            TargetHost = configuration.TargetHost;

            Listener = new TcpListener(LocalEndpoint);

            ServerThread = new Thread(RunThread);
            ServerThread.Name = "TransportLayerInsecurity Server";

            Running = false;

            ServerEventHandler = serverEventHandler;
        }
 public void SetupSubscribers(ServerCore server, IServerEventHandler serverCoreEventHandler)
 {
     serverCoreEventHandler.SubScribeClientLeft(new ServerEventHandlerDelegates.ClientLeftEvent(SharedClientServerGameObjectMessagesWrapperEvents.GetClientLeftEvent));
 }