Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetGroupSceneItemList #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsTron
Copy link
Contributor

@jsTron jsTron commented Sep 8, 2022

  • Fix string conversion in GetGroupSceneItemList.
  • Refactor get scene list method in test client and support top level groups.

@@ -1744,7 +1744,7 @@ public List<JObject> GetGroupSceneItemList(string sceneName)
};

var response = SendRequest(nameof(GetGroupSceneItemList), request);
return JsonConvert.DeserializeObject<List<JObject>>((string)response["sceneItems"]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other functions are in the format of (type)resonse["keyName"] is there a reason we're changing it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deserialization does not like the direct cast here, causing the request to hang. Now that you have me thinking, maybe changing List to something like a JArray could work as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was testing with my code, it was failing on line 1747 saying it couldn't convert from Array to String but I changed it to this and got it to work:

return JsonConvert.DeserializeObject<List<SceneItemDetails>>(response["sceneItems"].ToString());

You'll notice I also changed the overall function to return as SceneItemDetails like it was before but apparently for whatever reason the (string) isn't allowed whereas .ToString() is fine.


tvScenes.Nodes.Clear();
foreach (var scene in scenes)
{
var node = new TreeNode(scene.Name);
var sources = new List<SceneItemDetails>();
sources.AddRange(obs.GetSceneItemList(scene.Name));
foreach (var item in sources)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need all this in the test client?
Overall groups should be avoided per the Websocket documentation:
"Using groups at all in OBS is discouraged, as they are very broken under the hood."

https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#getgroupsceneitemlist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we don't. If I recall correctly, the previous code received and used that info for free from the old API. I was operating under the premise that I would mimic that behavior.

* Fix string conversion in GetGroupSceneItemList.
* Refactor get scene list method in test client and support top level groups.
@jsTron jsTron force-pushed the bugfix-getgroupsceneitemlist branch from 908a729 to 44c722b Compare October 13, 2022 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants