Example #1
0
    public static void RPC_S2C_WorkShopShared(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        RegisteredISO iso = stream.Read <RegisteredISO>();

        if (_SteamItems.ContainsKey(iso._hashCode))
        {
            _SteamItems[iso._hashCode] = iso._isoName;
        }
        _DownloadList.Add(iso);
        _CurDownloadList.Add(iso.UGCHandle);
    }
Example #2
0
    public static void RPC_S2C_SendFile(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        byte [] data  = stream.Read <byte[]> ();
        int     count = stream.Read <int> ();
        string  skey  = stream.Read <string> ();

        if (data != null && count != 0)
        {
            if (_FileSenderMgr.ContainsKey(skey) && _FileSenderMgr[skey] != null)
            {
                bool bFinish = false;
                _FileSenderMgr[skey].WriteData(data, count, ref bFinish);
                if (bFinish)
                {
                    RegisteredISO iso = _DownloadList.Find(iter => iter.UGCHandle == _FileSenderMgr[skey].m_FileHandle);
                    if (iso != null)
                    {
                        string fielName = VCConfig.s_CreationNetCachePath + _FileSenderMgr[skey].m_FileName + VCConfig.s_CreationNetCacheFileExt;
                        using (FileStream fs = new FileStream(fielName, FileMode.Create, FileAccess.Write, FileShare.Read))
                        {
                            fs.Write(_FileSenderMgr[skey].m_Data, 0, (int)_FileSenderMgr[skey].m_FileSize);
                        }

                        _DownloadList.RemoveAll(iter => iter.UGCHandle == _FileSenderMgr[skey].m_FileHandle);
                        Debug.Log(_DownloadList.Count().ToString() + "===========" + _FileSenderMgr[skey].m_FileName);
                        _SteamItems[iso._hashCode] = _FileSenderMgr[skey].m_FileName;
                    }

                    NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, _FileSenderMgr[skey].m_FileHandle);
                    _CurDownload = 0;
                    _FileSenderMgr.Remove(skey);
                    if (_DownloadList.Count <= 0)
                    {
                        RoomGui_N.SetMapInfo("Download complete");
                        if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow)
                        {
                            RoomGui_N.Instance.ActiveStartBtn();
                        }
                    }
                    else
                    {
                        RoomGui_N.SetMapInfo("Downloading " + _FileSenderMgr[skey].m_FileName + "...[100%]");
                    }

                    RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0);
                }
                else
                {
                    NetworkManager.SyncServer(EPacketType.PT_Common_UGCUpload, skey, count, true);
                }
            }
        }
    }
Example #3
0
    internal static void DownloadUGC()
    {
        try
        {
            RegisteredISO iso = _DownloadList.Find(iter => iter.UGCHandle == _CurDownload);
            if (null == iso)
            {
                _DownloadList.RemoveAll(iter => iter.UGCHandle == _CurDownload);
                _CurDownload = 0;
                return;
            }

            if (!_SteamItems.ContainsKey(iso._hashCode))
            {
                //if (_CurDownloadList.Contains(_CurDownload))
                //    return;
                UGCHandle_t handler;
                handler.m_UGCHandle = _CurDownload;

                SteamAPICall_t caller = SteamRemoteStorage.UGCDownload(handler, 0);
                //new CallResult<RemoteStorageDownloadUGCResult_t>(OnSteamUGCDownloadResult, caller);
                RemoteStorageDownloadPreUGCResult = CallResult <RemoteStorageDownloadUGCResult_t> .Create(OnSteamUGCDownloadResult);

                RemoteStorageDownloadPreUGCResult.Set(caller);
                RoomGui_N.SetMapInfo("Downloading " + iso._isoName + "...[0%]");
            }
            else
            {
                _DownloadList.RemoveAll(iter => iter.UGCHandle == _CurDownload);
                NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, _CurDownload);
                _CurDownload = 0;

                if (_DownloadList.Count <= 0)
                {
                    RoomGui_N.SetMapInfo("Download complete");
                    if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow)
                    {
                        RoomGui_N.Instance.ActiveStartBtn();
                    }
                }
                else
                {
                    RoomGui_N.SetMapInfo("Downloading " + iso._isoName + "...[100%]");
                }
            }

            RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0);
        }
        catch (Exception e)
        {
            LogManager.Warning(e.Message);
        }
    }
Example #4
0
    static void OnSteamUGCDownloadResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure)
    {
        Debug.Log("[SteamUGCDownloadResult] -- " + pCallback.m_eResult + " -- Name:" + pCallback.m_pchFileName + " -- Size:" + pCallback.m_nSizeInBytes);
        if (pCallback.m_eResult == EResult.k_EResultOK)
        {
            RegisteredISO iso = _DownloadList.Find(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle);
            if (iso != null)
            {
                string fielName = VCConfig.s_CreationNetCachePath + iso._hashCode.ToString("X").PadLeft(16, '0') + VCConfig.s_CreationNetCacheFileExt;
                byte[] fileData = new byte[pCallback.m_nSizeInBytes];
                int    length   = SteamRemoteStorage.UGCRead(pCallback.m_hFile, fileData, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close);

                using (FileStream fs = new FileStream(fielName, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    fs.Write(fileData, 0, length);
                }

                _DownloadList.RemoveAll(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle);
                _SteamItems[iso._hashCode] = pCallback.m_pchFileName;
            }

            if (BaseNetwork.MainPlayer.NetworkState == ENetworkState.Null)
            {
                NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, pCallback.m_hFile.m_UGCHandle);
            }
            else
            {
                for (int i = 0; i < _CurDownloadList.Count; i++)
                {
                    if (_CurDownloadList[i] == pCallback.m_hFile.m_UGCHandle)
                    {
                        NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, pCallback.m_hFile.m_UGCHandle);
                        _CurDownloadList[i] = 0;
                    }
                }
            }

            _CurDownload = 0;

            if (_DownloadList.Count <= 0)
            {
                RoomGui_N.SetMapInfo("Download complete");
                if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow)
                {
                    RoomGui_N.Instance.ActiveStartBtn();
                }
            }
            else
            {
                RoomGui_N.SetMapInfo("Downloading " + pCallback.m_pchFileName + "...[100%]");
            }

            RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0);
        }
        else if (pCallback.m_eResult == EResult.k_EResultFileNotFound)
        {
            Debug.LogWarning(pCallback.m_hFile.m_UGCHandle + " does not exits.");
            //_DownloadList.RemoveAll(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle);
            //_CurDownload = 0;
            //if (_DownloadList.Count <= 0)
            //{
            //    RoomGui_N.SetMapInfo("Download complete");
            //    if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow)
            //        RoomGui_N.Instance.ActiveStartBtn();
            //}
            //RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0);
            NetworkManager.SyncServer(EPacketType.PT_Common_InvalidUGC, _DownloadList[0]._hashCode, pCallback.m_hFile.m_UGCHandle);
        }
        else if (pCallback.m_eResult == EResult.k_EResultTimeout)
        {
            NetworkManager.SyncServer(EPacketType.PT_Common_DownTimeOut, _DownloadList[0]._hashCode, pCallback.m_hFile.m_UGCHandle);
        }
        else
        {
            RoomGui_N.SetMapInfo("Download failed");
            MessageBox_N.ShowYNBox(PELocalization.GetString(8000116), OnYesEvent, OnNoEvent);
        }
    }