Surface UPnP ALIVE delay through config

If you have a suggestion for a feature, post it here
Post Reply
PublicStaticVoidUser
Posts: 1
Joined: Mon Feb 01, 2016 4:03 pm

Surface UPnP ALIVE delay through config

Post by PublicStaticVoidUser »

Hi all,

I'm new to the project, and trying out a headless universalmediaserver instance with a PS4 renderer. The PS4's media player app sometimes takes a while to discover the already-running UMS instance, whereas launching UMS when Media Player is already open results in UMS instantly appearing.

My best guess is that's due to the UPnP ALIVE message backoff present in src/main/java/net/pms/network/UPNPHelper.java:

Code: Select all

	/**
	 * Starts up two threads: one to broadcast UPnP ALIVE messages and another
	 * to listen for responses.
	 *
	 * @throws IOException Signals that an I/O exception has occurred.
	 */
	public static void listen() throws IOException {
		Runnable rAlive = new Runnable() {
			@Override
			public void run() {
				int delay = 10000;

				while (true) {
					sleep(delay);
					sendAlive();

					// The first delay for sending an ALIVE message is 10 seconds,
					// the second delay is for 20 seconds. From then on, all other
					// delays are for 180 seconds.
					switch (delay) {
						case 10000:
							delay = 20000;
							break;
						case 20000:
							delay = 180000;
							break;
						default:
							break;
					}
				}
			}
		};
I'd want to change the 180 second delay to something surfaced from UMS.conf, but I'm not sure I understand Java well enough to do it properly (nor do I have a GUI to test with, and I assume that all options are also visible in the app somewhere). So, feature request!

Could someone add a long-term delay setting so that us silly PS4 owners don't have to wait on average 180/2 second before connecting to UMS?
(Or alternately, can someone tell me why I'm wrong about my analysis? :D)
Post Reply