Пример #1
0
 public static void SetEnableDebug(NetworkProtol np, bool debug)
 {
     if (np == NetworkProtol.Tcp)
     {
         m_TcpNet.SetEnableDebug(debug);
     }
 }
Пример #2
0
 public static bool GetEnableDebug(NetworkProtol np)
 {
     if (np == NetworkProtol.Tcp)
     {
         return(m_TcpNet.GetEnableDebug());
     }
     return(false);
 }
Пример #3
0
 public static void StartNetwork(NetworkProtol np)
 {
     if (np == NetworkProtol.Tcp)
     {
         m_TcpNet = new ClientNet();
     }
     else if (np == NetworkProtol.Kcp)
     {
         //m_KcpNet = new KCPNet();
     }
 }
Пример #4
0
 public static void SendPacket(NetworkProtol np, WfPacket pak)
 {
     pak.Swap();
     if (np == NetworkProtol.Tcp)
     {
         m_TcpNet.SendPacket(pak);
     }
     else if (np == NetworkProtol.Kcp)
     {
         //m_KcpNet.SendPacket(pak);
     }
 }
Пример #5
0
 public static int GetServerPort(NetworkProtol np)
 {
     if (np == NetworkProtol.Tcp)
     {
         return(m_TcpNet.GetServerPort());
     }
     else if (np == NetworkProtol.Kcp)
     {
         return(0);// m_KcpNet.GetServerPort();
     }
     return(0);
 }
Пример #6
0
 public static string GetServerIP(NetworkProtol np)
 {
     if (np == NetworkProtol.Tcp)
     {
         return(m_TcpNet.GetServerIP());
     }
     else if (np == NetworkProtol.Kcp)
     {
         return("");// m_KcpNet.GetServerIP();
     }
     return("");
 }
Пример #7
0
 public static bool IsConnectState(NetworkProtol np, int state)
 {
     if (np == NetworkProtol.Tcp)
     {
         return(m_TcpNet != null && m_TcpNet.isConnectState(state));
     }
     else if (np == NetworkProtol.Kcp)
     {
         return(false); // m_KcpNet != null && m_KcpNet.isConnectState(state);
     }
     return(false);
 }
Пример #8
0
 public static bool IsNetRun(NetworkProtol np)
 {
     if (np == NetworkProtol.Tcp)
     {
         return(m_TcpNet != null && m_TcpNet.IsNetRun());
     }
     else if (np == NetworkProtol.Kcp)
     {
         return(false); //m_KcpNet != null && m_KcpNet.IsNetRun();
     }
     return(false);
 }
Пример #9
0
    public static void SendPacket(NetworkProtol np, ISerializePacket msg, ushort msgType)
    {
        WfPacket pak = PooledClassManager <WfPacket> .CreateClass();

        pak.InitWrite(msgType);
        msg.Serialize(pak);
        pak.Swap();
        if (np == NetworkProtol.Tcp)
        {
            SendPacket(np, pak);
        }
        else if (np == NetworkProtol.Kcp)
        {
            //WfPacket pak = new WfPacket(msgType, 548);
            SendPacket(np, pak);
        }
    }
Пример #10
0
 public static void Shutdown(NetworkProtol np)
 {
     if (np == NetworkProtol.Tcp)
     {
         if (m_TcpNet != null)
         {
             m_TcpNet.Shutdown();
         }
     }
     else if (np == NetworkProtol.Kcp)
     {
         //if(m_KcpNet!= null)
         //{
         //    m_KcpNet.Shutdown();
         //}
     }
 }
Пример #11
0
    //自己给自己发消息,用于测试
    public static void SendPacketToMe(NetworkProtol np, ISerializePacket msg, ushort msgType)
    {
        WfPacket pak = PooledClassManager <WfPacket> .CreateClass();

        pak.InitWrite(msgType);
        msg.Serialize(pak);
        pak.Swap();
        if (np == NetworkProtol.Tcp)
        {
            GameDll.PacketHandlerManager.ProcessPacket(pak);
        }
        else if (np == NetworkProtol.Kcp)
        {
            //KCPPacketHandlerMgr.GetInstance().ProcessPacket(pak);
        }
        pak.DestroyClass();
        pak = null;
    }