-
Notifications
You must be signed in to change notification settings - Fork 227
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
JSON-RPC: jamulusserver/getServerProfile: Add directory address #2467
Comments
I have it working. Will post a PR. I simply add a "directoryServer" key to the response and echo back whatever was passed on the command line as that is what is stored in the ServerList object. |
Also, what do you think about changing a few of the method names? For example jamulusserver/getServerProfile should just be getProfile. Same with setServerName (should just be jamulusserver/setName). There's some redundancy in the naming given that they are 'namespaced'. The jamulusclient/* method names seem fine. |
@Rob-NY Making it shorter makes sense to me. I did not spend any effort in naming methods properly, and since the RPC is still experimental, we can rename the method. |
Yes. I‘d split this in two PRs |
What if the server isn't running headless and nothing was passed on the command line? What if it was changed over JSON-RPC? All state should be retrieved from the (client or) server itself - don't trust anything that happens to by lying around outside that, as it could be stale. |
Might be a good idea to get it from Line 227 in 259545f
|
@dtinth - Yes, that's exactly what I did. @pljones my command line comment was misleading, sorry. My (poorly made) point was that it will return the directory server that is/was the desired directory server -- not necessarily that the server is actually registered with it; for which you could examine the 'registrationStatus' property of the response. This is a subtle point, but @hoffie 's original post here was looking for the directory server to which the server was registered. To deliver on that specifically, the DS name would only be populated if the Status was "registered". However, I thought it might be more useful to include the "target" DS alongside the status and let the RPC consumer figure out how they want to use the information. |
Sadly, GetDirectoryAddress() (edit: in server.cpp) does not get updated if a user chooses one of the official directories via the UI - this only returns the custom directory server address (which is always populated when headless). Do you think RPC consumers would rather see the directory TYPE and let them convert that to one of the standard directories, OR should the RPC code convert the type to the directory address:port for them? The way the standard directories are implemented is somewhat interesting. Choices:
or
edit: This comment is moot. The confusing issue is that GetDirectoryAddress() exists as a method in both server.cpp and NetworkUtils -- and they do different things. See comment below. |
This approach seems Jamu-listic and accounts for the fact that choosing "None" actually defaults to anygenre1 behind the scenes so we need to adjust. Does this work?
|
I thought @softins at least worked on changing that on GUI level? |
It probably doesn't matter for the rest of the code base. The issue for RPC is that in GetDirectoryAddress (utils.cpp), the switch 'default' catches types of NONE and AT_DEFAULT and returns the DEFAULT_SERVER (which is anygenre1). So the condition above is needed to differentiate between those choices which have different meanings in the RPC response. There were other conditional options I suppose, but this seemed the most readable. The point is that I can't just call NetworkUtils::GetDirectoryAddress() blindly because I'll get back anygenre1 even if None is the chosen directory server. From util.h:
From util.cpp:
|
If directoryType is AT_NONE, then GetDirectoryAddress MUST NOT be used. The result of calling it is UNDEFINED (yes, the code simply returns default server address - but that could change, it's not defined in the case of AT_NONE). Ideally you'd return directory type and ONLY if it's AT_CUSTOM return the address. |
That precisely what my suggested code does, above, with respect to adding directoryServer name to the RPC response requested here. |
We should define it, so that |
Guess so - whilst the method shouldn't be called, calling it should therefore return an invalid result rather than the wrong value. Any value that won't get you AT_CUSTOM if you try to set it will do -- and as it's a string, you get AT_CUSTOM pretty much for any string, I think. |
JSON-RPC: Add server directory name (#2467)
Has this feature been discussed and generally agreed?
No.
Describe the solution you'd like
Raised by @softins in #1975 (review)
Describe alternatives that have been considered
/
The text was updated successfully, but these errors were encountered: