private Func <object, string, object> GetCallbackMethod()
        {
            return((ret, error) => {
                if (error != null)
                {
                    this.error = error;
                    return null;
                }
                handle = null;
                var batch = (BatchObjectMessage)ret;
                foreach (var item in batch.array)
                {
                    T data = (T)item;
                    storage.SaveData(data);
                }

                /*Console.WriteLine($"New lastVisitedIndex: {batch.lastVisitedIndex}, old: {gamePointer}, eos: {batch.endOfStream}");
                 * if(gamePointer > batch.lastVisitedIndex) {
                 *  throw new Exception("Internal error: gamePointer > lastVisitedIndex");
                 * }*/

                gamePointer = batch.lastVisitedIndex;
                endOfStream = batch.endOfStream;
                return null;
            });
        }
Esempio n. 2
0
 void UnregisterCallback(CallbackHandle handle)
 {
     lock (this)
     {
         callbacks.Remove(handle);
     }
 }
            private void StartCreatingItem()
            {
                if (!Type.HasValue)
                {
                    throw new System.Exception("Editor.Type must be set when creating a new item!");
                }

                CreateItem = workshop.ugc.CreateItem(WorkshopUploadAppId, (SteamNative.WorkshopFileType)(uint) Type, OnItemCreated);
            }
        private void AskForData()
        {
            var param = new GetObjectsFromIndexMessage()
            {
                index = gamePointer, type = storage.Type
            };

            handle = ClientHandler.Instance.RemoteCall(Contracts.GetObjectsStartingFromIndex, param, GetCallbackMethod());
        }
    public Task <string> GetNodeNameAsync()
    {
        CallbackHandle <string> callbackHandle = this.getNodeNameHandler.AddCallback(this.ResponseTimeout);
        var serviceMessage = new ServiceMessage
        {
            Type = MessageType.GetNodeName.ToString()
        };

        this.ReadyMessage(serviceMessage);
        return(callbackHandle.TaskCompletionSource.Task);
    }
Esempio n. 6
0
            public IDisposable RegisterChangeCallback(Action <object> callback, object state)
            {
                CallbackHandle handle = new CallbackHandle(this, callback, state);

                lock (this)
                {
                    if (!closed)
                    {
                        callbacks.Add(handle);
                    }
                }
                return(handle);
            }
Esempio n. 7
0
            private void PublishChanges()
            {
                UpdateHandle = workshop.ugc.StartItemUpdate(workshop.steamworks.AppId, Id);

                if (Title != null)
                {
                    workshop.ugc.SetItemTitle(UpdateHandle, Title);
                }

                if (Description != null)
                {
                    workshop.ugc.SetItemDescription(UpdateHandle, Description);
                }

                if (Folder != null)
                {
                    workshop.ugc.SetItemContent(UpdateHandle, Folder);
                }

                if (Tags != null && Tags.Count > 0)
                {
                    workshop.ugc.SetItemTags(UpdateHandle, Tags.ToArray());
                }

                if (Visibility.HasValue)
                {
                    workshop.ugc.SetItemVisibility(UpdateHandle, (SteamNative.RemoteStoragePublishedFileVisibility)(uint) Visibility.Value);
                }

                if (PreviewImage != null)
                {
                    workshop.ugc.SetItemPreview(UpdateHandle, PreviewImage);   //  change preview image file for this item. pszPreviewFile points to local image file, which must be under 1MB in size
                }

                /*
                 *  workshop.ugc.SetItemUpdateLanguage( UpdateId, const char *pchLanguage ) = 0; // specify the language of the title or description that will be set
                 *  workshop.ugc.SetItemMetadata( UpdateId, const char *pchMetaData ) = 0; // change the metadata of an UGC item (max = k_cchDeveloperMetadataMax)
                 *  workshop.ugc.RemoveItemKeyValueTags( UpdateId, const char *pchKey ) = 0; // remove any existing key-value tags with the specified key
                 *  workshop.ugc.AddItemKeyValueTag( UpdateId, const char *pchKey, const char *pchValue ) = 0; // add new key-value tags for the item. Note that there can be multiple values for a tag.
                 *  workshop.ugc.AddItemPreviewFile( UpdateId, const char *pszPreviewFile, EItemPreviewType type ) = 0; //  add preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
                 *  workshop.ugc.AddItemPreviewVideo( UpdateId, const char *pszVideoID ) = 0; //  add preview video for this item
                 *  workshop.ugc.UpdateItemPreviewFile( UpdateId, uint32 index, const char *pszPreviewFile ) = 0; //  updates an existing preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
                 *  workshop.ugc.UpdateItemPreviewVideo( UpdateId, uint32 index, const char *pszVideoID ) = 0; //  updates an existing preview video for this item
                 *  workshop.ugc.RemoveItemPreview( UpdateId, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted)
                 */

                SubmitItemUpdate = workshop.ugc.SubmitItemUpdate(UpdateHandle, ChangeNote, OnChangesSubmitted);
            }
            private void OnItemCreated(SteamNative.CreateItemResult_t obj, bool Failed)
            {
                NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
                CreateItem.Dispose();
                CreateItem = null;

                if (obj.Result == SteamNative.Result.OK && !Failed)
                {
                    Id = obj.PublishedFileId;
                    PublishChanges();
                    return;
                }

                Error      = "Error creating new file: " + obj.Result.ToString() + "(" + obj.PublishedFileId + ")";
                Publishing = false;
            }
Esempio n. 9
0
            private void OnChangesSubmittedInternal(SteamNative.SubmitItemUpdateResult_t obj, bool Failed)
            {
                if (Failed)
                {
                    throw new System.Exception("CreateItemResult_t Failed");
                }

                UpdateHandle               = 0;
                SubmitItemUpdate           = null;
                NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
                Publishing = false;

                Error = obj.Result != SteamNative.Result.OK
                    ? $"Error publishing changes: {obj.Result} ({NeedToAgreeToWorkshopLegal})"
                    : null;

                OnChangesSubmitted?.Invoke((Result)obj.Result);
            }
Esempio n. 10
0
            private void OnChangesSubmitted(SteamNative.SubmitItemUpdateResult_t obj, bool Failed)
            {
                if (Failed)
                {
                    throw new System.Exception("CreateItemResult_t Failed");
                }

                SubmitItemUpdate           = null;
                NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
                Publishing = false;

                if (obj.Result == SteamNative.Result.OK)
                {
                    return;
                }

                Error = "Error publishing changes: " + obj.Result.ToString();
            }
Esempio n. 11
0
            private void OnItemCreated(SteamNative.CreateItemResult_t obj, bool Failed)
            {
                NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
                CreateItem.Dispose();
                CreateItem = null;

                if (obj.Result == SteamNative.Result.OK && !Failed)
                {
                    Error = null;
                    Id    = obj.PublishedFileId;
                    PublishChanges();
                    return;
                }

                Error      = $"Error creating new file: {obj.Result} ({obj.PublishedFileId})";
                Publishing = false;

                OnChangesSubmitted?.Invoke((Result)obj.Result);
            }
            private void PublishChanges()
            {
                UpdateHandle = workshop.ugc.StartItemUpdate(WorkshopUploadAppId, Id);

                if (Title != null)
                {
                    workshop.ugc.SetItemTitle(UpdateHandle, Title);
                }

                if (Description != null)
                {
                    workshop.ugc.SetItemDescription(UpdateHandle, Description);
                }

                if (Folder != null)
                {
                    var info = new System.IO.DirectoryInfo(Folder);

                    if (!info.Exists)
                    {
                        throw new System.Exception($"Folder doesn't exist ({Folder})");
                    }

                    workshop.ugc.SetItemContent(UpdateHandle, Folder);
                }

                if (Tags != null && Tags.Count > 0)
                {
                    workshop.ugc.SetItemTags(UpdateHandle, Tags.ToArray());
                }

                if (Visibility.HasValue)
                {
                    workshop.ugc.SetItemVisibility(UpdateHandle, (SteamNative.RemoteStoragePublishedFileVisibility)(uint) Visibility.Value);
                }

                for (int i = 0; i < Images.Count; i++)
                {
                    workshop.ugc.AddItemPreviewFile(UpdateHandle, Images[i], ItemPreviewType.Image);
                }

                for (int i = 0; i < Videos.Count; i++)
                {
                    workshop.ugc.AddItemPreviewVideo(UpdateHandle, Videos[i]);
                }

                if (PreviewImage != null)
                {
                    var info = new System.IO.FileInfo(PreviewImage);

                    if (!info.Exists)
                    {
                        throw new System.Exception($"PreviewImage doesn't exist ({PreviewImage})");
                    }

                    if (info.Length >= 1024 * 1024)
                    {
                        throw new System.Exception($"PreviewImage should be under 1MB ({info.Length})");
                    }

                    workshop.ugc.SetItemPreview(UpdateHandle, PreviewImage);
                }

                /*
                 *  workshop.ugc.SetItemUpdateLanguage( UpdateId, const char *pchLanguage ) = 0; // specify the language of the title or description that will be set
                 *  workshop.ugc.SetItemMetadata( UpdateId, const char *pchMetaData ) = 0; // change the metadata of an UGC item (max = k_cchDeveloperMetadataMax)
                 *  workshop.ugc.RemoveItemKeyValueTags( UpdateId, const char *pchKey ) = 0; // remove any existing key-value tags with the specified key
                 *  workshop.ugc.AddItemKeyValueTag( UpdateId, const char *pchKey, const char *pchValue ) = 0; // add new key-value tags for the item. Note that there can be multiple values for a tag.
                 *  workshop.ugc.AddItemPreviewFile( UpdateId, const char *pszPreviewFile, EItemPreviewType type ) = 0; //  add preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
                 *  workshop.ugc.AddItemPreviewVideo( UpdateId, const char *pszVideoID ) = 0; //  add preview video for this item
                 *  workshop.ugc.UpdateItemPreviewFile( UpdateId, uint32 index, const char *pszPreviewFile ) = 0; //  updates an existing preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
                 *  workshop.ugc.UpdateItemPreviewVideo( UpdateId, uint32 index, const char *pszVideoID ) = 0; //  updates an existing preview video for this item
                 *  workshop.ugc.RemoveItemPreview( UpdateId, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted)
                 */

                SubmitItemUpdate = workshop.ugc.SubmitItemUpdate(UpdateHandle, ChangeNote, OnChangesSubmitted);
            }
Esempio n. 13
0
            private void PublishChanges()
            {
                if (WorkshopUploadAppId == 0)
                {
                    throw new Exception("WorkshopUploadAppId should not be 0");
                }

                UpdateHandle = workshop.ugc.StartItemUpdate(WorkshopUploadAppId, Id);

                if (Title != null)
                {
                    workshop.ugc.SetItemTitle(UpdateHandle, Title);
                }

                if (Description != null)
                {
                    workshop.ugc.SetItemDescription(UpdateHandle, Description);
                }

                if (Folder != null)
                {
                    var info = new System.IO.DirectoryInfo(Folder);

                    if (!info.Exists)
                    {
                        throw new System.Exception($"Folder doesn't exist ({Folder})");
                    }

                    workshop.ugc.SetItemContent(UpdateHandle, Folder);
                }

                if (Tags != null && Tags.Count > 0)
                {
                    workshop.ugc.SetItemTags(UpdateHandle, Tags.ToArray());
                }

                if (Visibility.HasValue)
                {
                    workshop.ugc.SetItemVisibility(UpdateHandle, (SteamNative.RemoteStoragePublishedFileVisibility)(uint) Visibility.Value);
                }

                if (PreviewImage != null)
                {
                    var info = new System.IO.FileInfo(PreviewImage);

                    if (!info.Exists)
                    {
                        throw new System.Exception($"PreviewImage doesn't exist ({PreviewImage})");
                    }

                    if (info.Length >= 1024 * 1024)
                    {
                        throw new System.Exception($"PreviewImage should be under 1MB ({info.Length})");
                    }

                    workshop.ugc.SetItemPreview(UpdateHandle, PreviewImage);
                }

                if (MetaData != null)
                {
                    workshop.ugc.SetItemMetadata(UpdateHandle, MetaData);
                }

                if (KeyValues != null)
                {
                    foreach (var key in KeyValues)
                    {
                        foreach (var value in key.Value)
                        {
                            workshop.ugc.AddItemKeyValueTag(UpdateHandle, key.Key, value);
                        }
                    }
                }

                /*
                 *  workshop.ugc.SetItemUpdateLanguage( UpdateId, const char *pchLanguage ) = 0; // specify the language of the title or description that will be set
                 *  workshop.ugc.RemoveItemKeyValueTags( UpdateId, const char *pchKey ) = 0; // remove any existing key-value tags with the specified key
                 *  workshop.ugc.AddItemPreviewFile( UpdateId, const char *pszPreviewFile, EItemPreviewType type ) = 0; //  add preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
                 *  workshop.ugc.AddItemPreviewVideo( UpdateId, const char *pszVideoID ) = 0; //  add preview video for this item
                 *  workshop.ugc.UpdateItemPreviewFile( UpdateId, uint32 index, const char *pszPreviewFile ) = 0; //  updates an existing preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
                 *  workshop.ugc.UpdateItemPreviewVideo( UpdateId, uint32 index, const char *pszVideoID ) = 0; //  updates an existing preview video for this item
                 *  workshop.ugc.RemoveItemPreview( UpdateId, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted)
                 */

                SubmitItemUpdate = workshop.ugc.SubmitItemUpdate(UpdateHandle, ChangeNote, OnChangesSubmittedInternal);
            }