private void StartServer()
    {
        _clients = new List <IPeer>();

        if (useWs)
        {
            _server = new ServerSocketWs();
        }
        else
        {
            _server = new ServerSocketUnet();
        }

        _server.Connected    += ClientConnected;
        _server.Disconnected += ClientDisconnected;

        // Start listening
        Debug.Log("Server: listening on port " + port);
        _server.Listen(port);

        if (sendMessages)
        {
            StartCoroutine(SendMessages(1f));
        }
    }
Пример #2
0
        public virtual void StartServer(int port)
        {
            Socket.Listen(port);

            IsRunning = true;

            if (Started != null)
            {
                Started.Invoke();
            }

            if (LookForModules)
            {
                // Find modules
                var modules = LookInChildrenOnly
                    ? GetComponentsInChildren <ServerModuleBehaviour>()
                    : FindObjectsOfType <ServerModuleBehaviour>();

                // Add modules
                foreach (var module in modules)
                {
                    AddModule(module);
                }

                // Initialize modules
                InitializeModules();
            }
        }
 public void StartServer(ushort port, int maxPlayers, INetworkMediator netMediator)
 {
     networkMediator = netMediator;
     _socket.Listen(port, MAX_PARALLEL_CONNECTION_REQUEST);
     CancellationSource = new CancellationTokenSource();
     NetPlayerId        = AbstractFactory.Get <INetworkTypeFactory>().GetNew <IPlayerSignature>();
     Task.Run(ReadNetwork, CancellationSource.Token);
 }
Пример #4
0
 public void Start()
 {
     if (_socket.Listen(SpeedDateConfig.Network.Port))
     {
         _logger.Info("Started on port: " + SpeedDateConfig.Network.Port);
         Started?.Invoke();
     }
 }
Пример #5
0
        /// <summary>
        /// Start server with given port and ip
        /// </summary>
        /// <param name="listenToIp">IP который слшаем</param>
        /// <param name="listenToPort"></param>
        public virtual void StartServer(string listenToIp, int listenToPort)
        {
            if (IsRunning)
            {
                return;
            }

            MstProperties startInfo = new MstProperties();

            startInfo.Add("\tFPS is", Application.targetFrameRate);
            startInfo.Add("\tApp key", socket.ApplicationKey);
            startInfo.Add("\tSecure", socket.UseSecure);
            startInfo.Add("\tCertificate Path", !socket.UseSecure ? "Undefined" : socket.CertificatePath);
            startInfo.Add("\tCertificate Pass", string.IsNullOrEmpty(socket.CertificatePath) || !socket.UseSecure ? "Undefined" : "********");

            logger.Info($"Starting Server...\n{startInfo.ToReadableString(";\n", " ")}");

            socket.Listen(listenToIp, listenToPort);
            LookForModules();
            IsRunning = true;
            OnServerStartedEvent?.Invoke();
            OnStartedServer();
        }