Esempio n. 1
0
        public void Send <T>(NetCmdBase ncb)
        {
            Debug.Log("TCP = " + typeof(T).ToString());
            SendCmdPack scp;

            scp.Cmd  = ncb;
            scp.Hash = Utility.GetHash(typeof(T).ToString());// TypeSize<T>.HASH;
            if (_mSendList.HasSpace())
            {
                _mSendList.AddItem(scp);
            }
            else
            {
                LogMgr.Log("发送命令队列已满");
            }

            byte[] sendData = NetCmdHelper.CmdToBytes(_mSendList.GetItem(), 0);
            if (sendData != null)
            {
                Send(sendData);
            }
            else
            {
                Debug.LogError("发送数据异常");
            }
        }
Esempio n. 2
0
    public void Send <T>(NetCmdBase ncb)
    {
        SendCmdPack scp;

        scp.Cmd  = ncb;
        scp.Hash = TypeSize <T> .HASH;
        if (m_SendList.HasSpace())
        {
            m_SendList.AddItem(scp);
        }
        else
        {
            LogMgr.Log("发送命令队列已满");
        }
    }
Esempio n. 3
0
        public void Send <T>(NetCmdBase ncb)
        {
            Debug.Log("UDP = " + typeof(T).ToString());
            SendCmdPack scp;

            scp.Cmd  = ncb;
            scp.Hash = TypeSize <T> .HASH;
            if (_mSendList.HasSpace())
            {
                _mSendList.AddItem(scp);
            }
            else
            {
                LogMgr.Log("发送命令队列已满");
            }
        }
Esempio n. 4
0
    //资源有带前缀"ftp://"
    public DownloadData AddMultiResDownload(DownloadType dt, List <ServerIPData> serverList, List <DownResData> resList, object obj = null)
    {
        if (m_DownList.HasSpace() == false)
        {
            return(null);
        }
        MultiFileDownData mfdd = new MultiFileDownData();

        mfdd.CompletionList   = new MultiFileOK[resList.Count];
        mfdd.FTPIPList        = new List <ServerIPData>();
        mfdd.FileList         = new List <DownResData>();
        mfdd.OutsideRecvIndex = 0;
        mfdd.RecvCount        = 0;
        mfdd.CurrentRecvSize  = 0;
        mfdd.ExtraData        = obj;
        mfdd.RecvFileList     = new RecvFileDataFlag[resList.Count];
        List <ServerIPData> ipList1 = new List <ServerIPData>();
        List <ServerIPData> ipList2 = new List <ServerIPData>();

        for (int i = 0; i < serverList.Count; ++i)
        {
            if (serverList[i].ISP == ISP_TYPE || serverList[i].ISP == (byte)ISPType.ISP_YD || ISP_TYPE == (byte)ISPType.ISP_YD)
            {
                ipList1.Add(serverList[i]);
            }
            //else
            //  ipList2.Add(sip);
        }
        if (ipList1.Count == 0)
        {
            for (int i = 0; i < serverList.Count; ++i)
            {
                ipList1.Add(serverList[i]);
            }
        }
        for (int i = 0; i < resList.Count; ++i)
        {
            mfdd.RecvFileList[i] = new RecvFileDataFlag();
            DownResData drd = resList[i];
            string      url = drd.ResUrl.ToLower();
            int         idx = url.IndexOf("fishpublish");
            if (idx == -1)
            {
                return(null);
            }
            drd.ResUrl = url.Substring(idx, url.Length - idx);
            mfdd.FileList.Add(drd);
        }
        //将FTP排队
        for (int i = 0; i < ipList1.Count;)
        {
            int idx = Utility.Range(0, ipList1.Count);
            if (idx >= ipList1.Count)
            {
                idx = ipList1.Count - 1;
            }
            mfdd.FTPIPList.Add(ipList1[idx]);
            ipList1.RemoveAt(idx);
        }
        for (int i = 0; i < ipList2.Count;)
        {
            int idx = Utility.Range(0, ipList2.Count);
            if (idx >= ipList2.Count)
            {
                idx = ipList2.Count - 1;
            }
            mfdd.FTPIPList.Add(ipList2[idx]);
            ipList2.RemoveAt(idx);
        }
        DownloadData dd = new DownloadData(null, mfdd, dt);

        dd.DownState = DownloadState.DS_DOWNLOADING;
        m_DownList.AddItem(dd);
        return(dd);
    }