Inheritance: NetworkConnection
        internal void InternalConnectLocalServer(bool generateConnectMsg)
        {
            if (m_FreeMessages == null)
            {
                m_FreeMessages = new Stack <InternalMsg>();
                for (int i = 0; i < k_InitialFreeMessagePoolSize; i++)
                {
                    InternalMsg msg = new InternalMsg();
                    m_FreeMessages.Push(msg);
                }
            }

            m_LocalServer = NetworkServer.instance;
            m_Connection  = new ULocalConnectionToServer(m_LocalServer);
            SetHandlers(m_Connection);
            m_Connection.connectionId = m_LocalServer.AddLocalClient(this);
            m_AsyncConnect            = ConnectState.Connected;

            SetActive(true);
            RegisterSystemHandlers(true);

            if (generateConnectMsg)
            {
                PostInternalMessage(MsgType.Connect);
            }
            m_Connected = true;
        }
        internal void InternalConnectLocalServer(bool generateConnectMsg)
        {
            m_Connection = new ULocalConnectionToServer();
            SetHandlers(m_Connection);
            m_Connection.connectionId = NetworkServer.AddLocalClient(this);
            m_AsyncConnect            = ConnectState.Connected;

            SetActive(true);
            RegisterSystemHandlers(true);

            if (generateConnectMsg)
            {
                PostInternalMessage((short)MsgType.Connect);
            }
            m_Connected = true;
        }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 internal bool InvokeHandlerOnServer(ULocalConnectionToServer conn, short msgType, MessageBase msg, int channelId)
 {
     if (this.m_MessageHandlers.GetHandler(msgType) != null)
       {
     NetworkConnection networkConnection = this.m_Connections.Get(conn.connectionId);
     if (networkConnection != null)
     {
       ULocalConnectionToClient connectionToClient = (ULocalConnectionToClient) networkConnection;
       NetworkWriter writer = new NetworkWriter();
       msg.Serialize(writer);
       NetworkReader reader = new NetworkReader(writer);
       this.m_MessageHandlers.InvokeHandler(msgType, (NetworkConnection) connectionToClient, reader, channelId);
       return true;
     }
     if (LogFilter.logError)
       Debug.LogError((object) ("Local invoke: Failed to find local connection to invoke handler on [connectionId=" + (object) conn.connectionId + "]"));
     return false;
       }
       if (LogFilter.logError)
     Debug.LogError((object) ("Local invoke: Failed to find message handler for message ID " + (object) msgType));
       return false;
 }
Ejemplo n.º 5
0
 internal bool InvokeBytes(ULocalConnectionToServer conn, byte[] buffer, int numBytes, int channelId)
 {
     NetworkReader reader = new NetworkReader(buffer);
       int num = (int) reader.ReadInt16();
       short msgType = reader.ReadInt16();
       if (this.m_MessageHandlers.GetHandler(msgType) != null)
       {
     NetworkConnection networkConnection = this.m_Connections.Get(conn.connectionId);
     if (networkConnection != null)
     {
       ULocalConnectionToClient connectionToClient = (ULocalConnectionToClient) networkConnection;
       this.m_MessageHandlers.InvokeHandler(msgType, (NetworkConnection) connectionToClient, reader, channelId);
       return true;
     }
       }
       return false;
 }
Ejemplo n.º 6
0
 internal bool InvokeHandlerOnServer(ULocalConnectionToServer conn, short msgType, MessageBase msg, int channelId)
 {
     if (handlers.ContainsKey(msgType) && (this.m_LocalConnection != null))
     {
         NetworkWriter writer = new NetworkWriter();
         msg.Serialize(writer);
         NetworkReader reader = new NetworkReader(writer);
         this.m_LocalConnection.InvokeHandler(msgType, reader, channelId);
         return true;
     }
     if (LogFilter.logError)
     {
         Debug.LogError(string.Concat(new object[] { "Local invoke: Failed to find local connection to invoke handler on [connectionId=", conn.connectionId, "] for MsgId:", msgType }));
     }
     return false;
 }
Ejemplo n.º 7
0
 internal bool InvokeBytes(ULocalConnectionToServer conn, byte[] buffer, int numBytes, int channelId)
 {
     NetworkReader reader = new NetworkReader(buffer);
     reader.ReadInt16();
     short key = reader.ReadInt16();
     if (handlers.ContainsKey(key) && (this.m_LocalConnection != null))
     {
         this.m_LocalConnection.InvokeHandler(key, reader, channelId);
         return true;
     }
     return false;
 }