function waitForResponse(id, expectedResponse = undefined, repeating = false) {
	return new Promise((resolve, reject) => {
		let listener = function(response) {
			logToConsole("waitForResponseListener: response=" + response + " expectedResponse=" + expectedResponse + " repeating=" + repeating);
			if (!expectedResponse || expectedResponse === response) {
				eventEmitter.removeListener(id, listener);
				resolve(response);
			} else if (!repeating) {
				eventEmitter.removeListener(id, listener);
				reject("Returned response (" + response + ") does not match expected (" + expectedResponse + ")");
			}
		};

		eventEmitter.on(id, listener);
	});
}
/**
 * Waits for a response from the web socket.
 *
 * An expected response can be defined and the promise is rejected if it is not repeating
 * and the returned response does not equal the expected response.
 *
 * The response can be repeating. If this is the case the promise will never get rejected.
 * Repeating is used in the situations where we are polling for a particular response in
 * situations where we can not bind to a particular event.
 */
Waits for a response from the web socket.
An expected response can be defined and the promise is rejected if it is not repeating
and the returned response does not equal the expected response.

The response can be repeating. If this is the case the promise will never get rejected.
Repeating is used in the situations where we are polling for a particular response in
situations where we can not bind to a particular event.
Waits for a response from the web socket . An expected response can be defined and the promise is rejected if it is not repeating and the returned response does not equal the expected response . The response can be repeating . If this is the case the promise will never get rejected . Repeating is used in the situations where we are polling for a particular response in situations where we can not bind to a particular event .
function waitForResponse(id, expectedResponse = undefined, repeating = false) {
	return new Promise((resolve, reject) => {
		let listener = function(response) {
			logToConsole("waitForResponseListener: response=" + response + " expectedResponse=" + expectedResponse + " repeating=" + repeating);
			if (!expectedResponse || expectedResponse === response) {
				eventEmitter.removeListener(id, listener);
				resolve(response);
			} else if (!repeating) {
				eventEmitter.removeListener(id, listener);
				reject("Returned response (" + response + ") does not match expected (" + expectedResponse + ")");
			}
		};
		eventEmitter.on(id, listener);
	});
}
function waitForResponse ( id , expectedResponse = undefined , repeating = false ) { return new Promise ( ( resolve , reject ) => { let listener = function ( response ) { logToConsole ( "waitForResponseListener: response=" + response + " expectedResponse=" + expectedResponse + " repeating=" + repeating ) ; if ( ! expectedResponse || expectedResponse === response ) { eventEmitter . removeListener ( id , listener ) ; resolve ( response ) ; } else if ( ! repeating ) { eventEmitter . removeListener ( id , listener ) ; reject ( "Returned response (" + response + ") does not match expected (" + expectedResponse + ")" ) ; } } ; eventEmitter . on ( id , listener ) ; } ) ; }
Waits for a response from the web socket.
Waits for a response from the web socket .