Esempio n. 1
0
        public ClientManager(NetClient client)
        {
            m_client = client;

            m_responseListener = new ReliableEventResponseListener(ReleaseReliable);
            Network.AddListener(m_responseListener);
        }
    IEnumerator CoroutineConnect(string serverIp, int myPort, int serverPort, System.Action callback = null)
    {
        Debug.Log("Connection try started");
        Network.InitAsClient(serverIp, myPort, serverPort);
        while (Network.Client.ConnectionId < 0)
        {
            yield return(null);
        }
        yield return(null);

        if (callback != null)
        {
            callback();
        }
        if (OnConnect != null)
        {
            OnConnect(this, Network.Client.ConnectionId);
        }
        Network.AddListener(new RespawnListener());
        Debug.Log("Connected");

        yield return(new WaitForSeconds(1.0f));

        {
            var e = new SpawnRequestEvent(Network.Client.ConnectionId);

            Network.Client.Send(e);
        }
    }
Esempio n. 3
0
 public void Init()
 {
     if (!initialized)
     {
         m_listenerOfStates = new StateListener(this);
         m_shotListener     = new ShotListener(this);
         Network.AddListener(m_listenerOfStates);
         Network.AddListener(m_shotListener);
         initialized = true;
     }
 }
Esempio n. 4
0
    public void Init()
    {
        m_inputListener = new ProperInputListener(this);
        m_spawnListener = new ProperPleaseSpawnListener(this);
        m_shotListener  = new ProperShotListener(this);
        Network.AddListener(m_inputListener);
        Network.AddListener(m_spawnListener);
        Network.AddListener(m_shotListener);

        updateThread = new Thread(UpdateLoop);
        updateThread.Start();
    }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Network.Init(true);
            Network.AddListener(new TestInputLstener());

            Console.WriteLine("SERVER APP Launched.\n==========");

            while (true)
            {
                Thread.Sleep(16);
                Network.Server.ResendRemainingReliables();
            }
        }
Esempio n. 6
0
        public ServerManager(NetServer server)
        {
            m_server = server;
            World    = new World();
            World.Init();
            m_server.OnDisconnect += OnDisconnect;

            updateThread = new Thread(TimelyCheck);
            updateThread.Start();

            m_responseListener = new ReliableEventResponseListener((int i) => { TryReleaseReliable(i); });
            Network.AddListener(m_responseListener);
        }