Пример #1
0
 private void PrepareForConnect(bool usePlatformSpecificProtocols)
 {
     NetworkClient.SetActive(true);
     this.RegisterSystemHandlers(false);
     if (this.m_HostTopology == null)
     {
         ConnectionConfig defaultConfig = new ConnectionConfig();
         int num1 = (int)defaultConfig.AddChannel(QosType.Reliable);
         int num2 = (int)defaultConfig.AddChannel(QosType.Unreliable);
         defaultConfig.UsePlatformSpecificProtocols = usePlatformSpecificProtocols;
         this.m_HostTopology = new HostTopology(defaultConfig, 8);
     }
     if (this.m_UseSimulator)
     {
         int minTimeout = this.m_SimulatedLatency / 3 - 1;
         if (minTimeout < 1)
         {
             minTimeout = 1;
         }
         int maxTimeout = this.m_SimulatedLatency * 3;
         if (LogFilter.logDebug)
         {
             Debug.Log((object)("AddHost Using Simulator " + (object)minTimeout + "/" + (object)maxTimeout));
         }
         this.m_ClientId = NetworkTransport.AddHostWithSimulator(this.m_HostTopology, minTimeout, maxTimeout, 0);
     }
     else
     {
         this.m_ClientId = NetworkTransport.AddHost(this.m_HostTopology, 0);
     }
 }
Пример #2
0
 public void Shutdown()
 {
     if (LogFilter.logDebug)
     {
         Debug.Log("Shutting down client " + this.m_ClientId);
     }
     this.m_ClientId = -1;
     NetworkClient.RemoveClient(this);
     if (NetworkClient.s_Clients.Count == 0)
     {
         NetworkClient.SetActive(false);
     }
 }
Пример #3
0
 public NetworkClient(NetworkConnection conn)
 {
     if (LogFilter.logDev)
     {
         Debug.Log("Client created version " + Version.Current);
     }
     this.m_MsgBuffer = new byte[65535];
     this.m_MsgReader = new NetworkReader(this.m_MsgBuffer);
     NetworkClient.AddClient(this);
     NetworkClient.SetActive(true);
     this.m_Connection   = conn;
     this.m_AsyncConnect = NetworkClient.ConnectState.Connected;
     conn.SetHandlers(this.m_MessageHandlers);
     this.RegisterSystemHandlers(false);
 }
Пример #4
0
 /// <summary>
 ///   <para>Shut down a client.</para>
 /// </summary>
 public void Shutdown()
 {
     if (LogFilter.logDebug)
     {
         Debug.Log((object)("Shutting down client " + (object)this.m_ClientId));
     }
     if (this.m_ClientId != -1)
     {
         NetworkTransport.RemoveHost(this.m_ClientId);
         this.m_ClientId = -1;
     }
     NetworkClient.RemoveClient(this);
     if (NetworkClient.s_Clients.Count != 0)
     {
         return;
     }
     NetworkClient.SetActive(false);
 }
Пример #5
0
 internal void InternalConnectLocalServer()
 {
     if (m_FreeMessages == null)
     {
         m_FreeMessages = new Stack <InternalMsg>();
         for (int i = 0; i < 64; i++)
         {
             m_FreeMessages.Push(default(InternalMsg));
         }
     }
     m_LocalServer = NetworkServer.instance;
     m_Connection  = new ULocalConnectionToServer(m_LocalServer);
     SetHandlers(m_Connection);
     m_Connection.connectionId = m_LocalServer.AddLocalClient(this);
     m_AsyncConnect            = ConnectState.Connected;
     NetworkClient.SetActive(state: true);
     RegisterSystemHandlers(localClient: true);
     PostInternalMessage(32);
     m_Connected = true;
 }
Пример #6
0
 internal void InternalConnectLocalServer()
 {
     if (this.m_FreeMessages == null)
     {
         this.m_FreeMessages = new Stack <InternalMsg>();
         for (int i = 0; i < 0x40; i++)
         {
             InternalMsg item = new InternalMsg();
             this.m_FreeMessages.Push(item);
         }
     }
     this.m_LocalServer = NetworkServer.instance;
     base.m_Connection  = new ULocalConnectionToServer(this.m_LocalServer);
     base.SetHandlers(base.m_Connection);
     base.m_Connection.connectionId = this.m_LocalServer.AddLocalClient(this);
     base.m_AsyncConnect            = NetworkClient.ConnectState.Connected;
     NetworkClient.SetActive(true);
     base.RegisterSystemHandlers(true);
     this.PostInternalMessage(0x20);
     this.m_Connected = true;
 }
Пример #7
0
 internal void InternalConnectLocalServer(bool generateConnectMsg)
 {
     if (this.m_FreeMessages == null)
     {
         this.m_FreeMessages = new Stack <LocalClient.InternalMsg>();
         for (int index = 0; index < 64; ++index)
         {
             this.m_FreeMessages.Push(new LocalClient.InternalMsg());
         }
     }
     this.m_LocalServer = NetworkServer.instance;
     this.m_Connection  = (NetworkConnection) new ULocalConnectionToServer(this.m_LocalServer);
     this.SetHandlers(this.m_Connection);
     this.m_Connection.connectionId = this.m_LocalServer.AddLocalClient(this);
     this.m_AsyncConnect            = NetworkClient.ConnectState.Connected;
     NetworkClient.SetActive(true);
     this.RegisterSystemHandlers(true);
     if (generateConnectMsg)
     {
         this.PostInternalMessage((short)32);
     }
     this.m_Connected = true;
 }
Пример #8
0
 private void PrepareForConnect(bool usePlatformSpecificProtocols)
 {
     NetworkClient.SetActive(true);
     this.RegisterSystemHandlers(false);
     if (this.m_HostTopology == null)
     {
         ConnectionConfig connectionConfig = new ConnectionConfig();
         connectionConfig.AddChannel(QosType.ReliableSequenced);
         connectionConfig.AddChannel(QosType.Unreliable);
         connectionConfig.UsePlatformSpecificProtocols = usePlatformSpecificProtocols;
         this.m_HostTopology = new HostTopology(connectionConfig, 8);
     }
     if (this.m_UseSimulator)
     {
         int num = this.m_SimulatedLatency / 3 - 1;
         if (num < 1)
         {
             num = 1;
         }
         int num2 = this.m_SimulatedLatency * 3;
         if (LogFilter.logDebug)
         {
             Debug.Log(string.Concat(new object[]
             {
                 "AddHost Using Simulator ",
                 num,
                 "/",
                 num2
             }));
         }
         this.m_ClientId = NetworkTransport.AddHostWithSimulator(this.m_HostTopology, num, num2, this.m_HostPort);
     }
     else
     {
         this.m_ClientId = NetworkTransport.AddHost(this.m_HostTopology, this.m_HostPort);
     }
 }
Пример #9
0
 internal void InternalConnectLocalServer(bool generateConnectMsg)
 {
     if (this.m_FreeMessages == null)
     {
         this.m_FreeMessages = new Stack <LocalClient.InternalMsg>();
         for (int i = 0; i < 64; i++)
         {
             LocalClient.InternalMsg t = default(LocalClient.InternalMsg);
             this.m_FreeMessages.Push(t);
         }
     }
     this.m_LocalServer = NetworkServer.instance;
     this.m_Connection  = new ULocalConnectionToServer(this.m_LocalServer);
     base.SetHandlers(this.m_Connection);
     this.m_Connection.connectionId = this.m_LocalServer.AddLocalClient(this);
     this.m_AsyncConnect            = NetworkClient.ConnectState.Connected;
     NetworkClient.SetActive(true);
     base.RegisterSystemHandlers(true);
     if (generateConnectMsg)
     {
         this.PostInternalMessage(32);
     }
     this.m_Connected = true;
 }