Ejemplo n.º 1
0
 public static void SendCacheIso(ulong hash)
 {
     if (SendIsoCacheMgr.ContainsKey(hash))
     {
         SendIsoCache  iso  = SendIsoCacheMgr[hash];
         SteamFileItem item = new SteamFileItem(iso.callBackSteamUploadResult, iso.name, iso.desc, iso.preData, iso.data, iso.hash, iso.tags, iso.bPublish, iso.sendToServer, iso.id, 0, true);
         item.StartSend();
         RemoveIsoCache(iso);
     }
 }
Ejemplo n.º 2
0
    internal static void SendFile(SteamUploadEventHandler callBackSteamUploadResult, string name, string desc, byte[] preData, byte[] data, string[] tags, bool sendToServer = true, int id = -1, ulong fileId = 0, bool free = false)
    {
        ulong hash = CRC64.Compute(data);
        bool  ret  = false;

        try
        {
            if (string.IsNullOrEmpty(name))
            {
                VCEMsgBox.Show(VCEMsgBoxType.EXPORT_EMPTY_NAME);
                LogManager.Error("File name cannot be null.");
                return;
            }
            if (!SteamUser.BLoggedOn())
            {
                LogManager.Error("log back in steam...");
                return;
            }

            bool bPublish = !sendToServer;
            if (SteamRemoteStorage.FileExists(hash.ToString() + "_preview"))
            {            //file exist,don't publish it;
            }

            if (!SteamRemoteStorage.IsCloudEnabledForAccount())
            {
                throw new Exception("Account cloud disabled.");
            }

            if (!SteamRemoteStorage.IsCloudEnabledForApp())
            {
                throw new Exception("App cloud disabled.");
            }
            if (!bPublish)
            {
                SteamFileItem item = new SteamFileItem(callBackSteamUploadResult, name, desc, preData, data, hash, tags, bPublish, sendToServer, id, fileId, free);
                item.StartSend();
            }
            else
            {
                SendIsoCache iso = new SendIsoCache();
                iso.id           = id;
                iso.hash         = hash;
                iso.name         = name;
                iso.preData      = preData;
                iso.sendToServer = sendToServer;
                iso.tags         = tags;
                iso.data         = data;
                iso.desc         = desc;
                iso.callBackSteamUploadResult = callBackSteamUploadResult;
                iso.bPublish = bPublish;
                if (AddToIsoCache(iso))
                {
                    LobbyInterface.LobbyRPC(ELobbyMsgType.UploadISO, hash, SteamMgr.steamId.m_SteamID);
                }
                else
                {
                    return;
                }
            }

            VCEMsgBox.Show(VCEMsgBoxType.EXPORT_NETWORK);
            ret = true;
        }
        catch (Exception e)
        {
            VCEMsgBox.Show(VCEMsgBoxType.EXPORT_NETWORK_FAILED);
            Debug.LogWarning("workshop error :" + e.Message);
            ToolTipsMgr.ShowText(e.Message);
        }
        finally
        {
            if (!ret && callBackSteamUploadResult != null)
            {
                callBackSteamUploadResult(id, false, hash);
            }
        }
    }