private void PostInternalMessage(byte[] buffer, int channelId)
 {
     LocalClient.InternalMsg internalMsg = this.m_FreeMessages.Count != 0 ? this.m_FreeMessages.Pop() : new LocalClient.InternalMsg();
     internalMsg.buffer    = buffer;
     internalMsg.channelId = channelId;
     this.m_InternalMsgs.Add(internalMsg);
 }
Beispiel #2
0
 private void ProcessInternalMessages()
 {
     if (this.m_InternalMsgs.Count != 0)
     {
         List <LocalClient.InternalMsg> internalMsgs = this.m_InternalMsgs;
         this.m_InternalMsgs = this.m_InternalMsgs2;
         for (int i = 0; i < internalMsgs.Count; i++)
         {
             LocalClient.InternalMsg t = internalMsgs[i];
             if (this.s_InternalMessage.reader == null)
             {
                 this.s_InternalMessage.reader = new NetworkReader(t.buffer);
             }
             else
             {
                 this.s_InternalMessage.reader.Replace(t.buffer);
             }
             this.s_InternalMessage.reader.ReadInt16();
             this.s_InternalMessage.channelId = t.channelId;
             this.s_InternalMessage.conn      = base.connection;
             this.s_InternalMessage.msgType   = this.s_InternalMessage.reader.ReadInt16();
             this.m_Connection.InvokeHandler(this.s_InternalMessage);
             this.m_FreeMessages.Push(t);
             base.connection.lastMessageTime = Time.time;
         }
         this.m_InternalMsgs = internalMsgs;
         this.m_InternalMsgs.Clear();
         for (int j = 0; j < this.m_InternalMsgs2.Count; j++)
         {
             this.m_InternalMsgs.Add(this.m_InternalMsgs2[j]);
         }
         this.m_InternalMsgs2.Clear();
     }
 }
        private void ProcessInternalMessages()
        {
            if (this.m_InternalMsgs.Count == 0)
            {
                return;
            }
            List <LocalClient.InternalMsg> internalMsgs = this.m_InternalMsgs;

            this.m_InternalMsgs = this.m_InternalMsgs2;
            using (List <LocalClient.InternalMsg> .Enumerator enumerator = internalMsgs.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    LocalClient.InternalMsg current = enumerator.Current;
                    if (this.s_InternalMessage.reader == null)
                    {
                        this.s_InternalMessage.reader = new NetworkReader(current.buffer);
                    }
                    else
                    {
                        this.s_InternalMessage.reader.Replace(current.buffer);
                    }
                    int num = (int)this.s_InternalMessage.reader.ReadInt16();
                    this.s_InternalMessage.channelId = current.channelId;
                    this.s_InternalMessage.conn      = this.connection;
                    this.s_InternalMessage.msgType   = this.s_InternalMessage.reader.ReadInt16();
                    this.m_Connection.InvokeHandler(this.s_InternalMessage);
                    this.m_FreeMessages.Push(current);
                    this.connection.lastMessageTime = Time.time;
                }
            }
            this.m_InternalMsgs = internalMsgs;
            this.m_InternalMsgs.Clear();
            using (List <LocalClient.InternalMsg> .Enumerator enumerator = this.m_InternalMsgs2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    this.m_InternalMsgs.Add(enumerator.Current);
                }
            }
            this.m_InternalMsgs2.Clear();
        }
Beispiel #4
0
 internal void InternalConnectLocalServer()
 {
     if (this.m_FreeMessages == null)
     {
         this.m_FreeMessages = new Stack <LocalClient.InternalMsg>();
         for (int i = 0; i < 64; i++)
         {
             LocalClient.InternalMsg item = default(LocalClient.InternalMsg);
             this.m_FreeMessages.Push(item);
         }
     }
     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);
     this.PostInternalMessage(32);
     this.m_Connected = true;
 }