Ejemplo n.º 1
0
 // 创建事件ID和name的映射表.
 void AddEventMapping(string name, GameEventID eventId)
 {
     if (mEventDefines.ContainsKey(name) == true)
     {
         CommonDebugLog.Log(" The event " + name + "already contains a definition for EventMapping");
     }
     else if (mEventDefines.ContainsValue(eventId) == true)
     {
         CommonDebugLog.Log(" The event " + name + "already contains a definition for EventMapping");
     }
     else
     {
         mEventDefines[name] = eventId;
     }
 }
Ejemplo n.º 2
0
 public void SeeEveryNode()
 {
     for (Int32 i = 0; i < keyList.size; ++i)
     {
         if ((bool)hashTableStatus[keyList[i]] == true)
         {
             System.Object obj = hashTableObjs[keyList[i]];
             CommonDebugLog.Log(obj.ToString());
         }
         else
         {
             System.Object obj = hashTableObjs[keyList[i]];
             CommonDebugLog.Log(obj.ToString());
         }
     }
 }
Ejemplo n.º 3
0
        //-- 将从socket接收到的数据,拷贝到LogicRecvBuf中。
        private static void OnReceive(object sender, SocketAsyncEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (e.LastOperation != SocketAsyncOperation.Receive)
            {
                return;
            }

            if (e.SocketError != SocketError.Success)
            {
                return;
            }

            OnRecvObj recvData = e.UserToken as OnRecvObj;

            if (recvData == null)
            {
                return;
            }

            if (recvData.m_RecvBuffer == null)
            {
                return;
            }

            if (recvData.m_LogicRecvHandler == null)
            {
                return;
            }

            if (recvData.m_TSocket == null)
            {
                return;
            }

            LogicRecvBufQueue logicRecvBufQueue = recvData.m_LogicRecvHandler.GetLogicRecvBufQueue();

            if (logicRecvBufQueue == null)
            {
                //-- log
                return;
            }

            LogicRecvBuffer logicRecvBuf = logicRecvBufQueue.GetEmptyBuf();

            if (logicRecvBuf == null)
            {
                //-- log
                return;
            }

            MemoryStream memStream = logicRecvBuf.GetMemoryStream();

            if (memStream == null)
            {
                //-- log
                return;
            }

            if (e.BytesTransferred > 0)
            {
                //-- test
                //Console.WriteLine("e.BytesTransferred:=[" + e.BytesTransferred + "]");

                //-- 拷贝数据要从memStream的头写入。
                memStream.Seek(0, SeekOrigin.Begin);
                memStream.Write(e.Buffer, 0, e.BytesTransferred);
                memStream.Seek(0, SeekOrigin.Begin);
                logicRecvBuf.SetUsedFlag(true);
                //-- 释放recvData.m_RecvBuffer
                recvData.m_RecvBuffer.SetUsedFlag(false);
                //-- 继续接收
                recvData.m_TSocket.RecvFromSocketBuf(recvData.m_LogicRecvHandler);
            }
            else
            {
                recvData.m_RecvBuffer.SetUsedFlag(false);
                //-- log查看是否接收缓冲区满了
                CommonDebugLog.Log("Server DisConnect!!!");
                NetClient.GetInstance().Disconnect();
            }
            return;
        }