Esempio n. 1
0
        public async Task Start()
        {
            if (UsersManager == null)
            {
                throw new InvalidOperationException($"{nameof(UsersManager)} is null");
            }

            if (DependencyStorage == null)
            {
                throw new InvalidOperationException($"{nameof(DependencyStorage)} is null");
            }

            if (ServiceManager == null)
            {
                throw new InvalidOperationException($"{nameof(ServiceManager)} is null");
            }

            InitializeServices();

            InternalTcp.MessageReceived += InternalServerMessageReceived;

            await InternalTcp.StartAsync();

            AudioBroadcaster.Start();
        }
Esempio n. 2
0
        public async Task Stop()
        {
            InternalTcp.MessageReceived -= InternalServerMessageReceived;

            await InternalTcp.StopAsync();

            AudioBroadcaster.Stop();
        }
Esempio n. 3
0
        public MidgeServer(int port, X509Certificate certificate)
        {
            Ip          = new IPEndPoint(IPAddress.Any, port);
            Certificate = certificate;

            InternalTcp = new TcpSslServer(Ip, Certificate);
            InternalUdp = new UdpServer(port + 1);

            UsersManager     = new MidgeUsersManager(InternalTcp);
            AudioBroadcaster = new AudioBroadcaster(InternalUdp);
            ServiceManager   = new MidgeServiceManager();

            _clientMessageParser = new ClientMessageParser();
            _serverMessageParser = new ServerMessageParser();
            _controllerFactory   = new MidgeControllerFactory(new MidgeControllerParser());
        }