diff --git a/app/assets/javascripts/fakeJamClient.js b/app/assets/javascripts/fakeJamClient.js index 65c554dbd..e39bb10f9 100644 --- a/app/assets/javascripts/fakeJamClient.js +++ b/app/assets/javascripts/fakeJamClient.js @@ -17,12 +17,29 @@ eval(js); } + function GetASIODevices(callbackFunctionName) { + var response = {'todo':'fill me in'}; + var js = callbackFunctionName + "(" + JSON.stringify(response) + ");"; + eval(js); + } + + function TestAudioDevice(deviceId, callbackFunctionName) { + var response = { + deviceId: deviceId, + deviceLatencyMS: 5.3 + }; + var js = callbackFunctionName + "(" + JSON.stringify(response) + ");"; + eval(js); + } + function joinSession(sessionId) {} function participantLeft(session, participant) {} function participantJoined(session, participant) {} // Javascript Bridge seems to camel-case this.TestLatency = testLatency; + this.GetASIODevices = GetASIODevices; + this.TestAudioDevice = TestAudioDevice; this.JoinSession = joinSession; this.ParticipantLeft = participantLeft; this.ParticipantJoined = participantJoined; diff --git a/app/assets/javascripts/jamkazam.js b/app/assets/javascripts/jamkazam.js index 1dac15556..8cb752bbe 100644 --- a/app/assets/javascripts/jamkazam.js +++ b/app/assets/javascripts/jamkazam.js @@ -71,8 +71,6 @@ } function loggedIn(header, payload) { - logger.debug('loggedIn'); - logger.debug(payload); app.clientId = payload.client_id; } diff --git a/app/assets/javascripts/testBridge.js b/app/assets/javascripts/testBridge.js index 3a4191d19..2be2db69a 100644 --- a/app/assets/javascripts/testBridge.js +++ b/app/assets/javascripts/testBridge.js @@ -12,12 +12,11 @@ sessionId: '#testBridge-createdSessionId', jSession: '#testBridge-joinSession', testLatency: '#testBridge-TestLatency', - testLatencyResponse: '#testBridge-TestLatencyResponse' + testLatencyResponse: '#testBridge-TestLatencyResponse', + getDevices: '#testBridge-GetDevices' }; - function afterShow(data) { - app.subscribe(context.JK.MessageType.LOGIN_ACK, loggedIn); - } + function afterShow(data) {} function loggedIn(header, payload) { var clientId = payload.client_id; @@ -88,22 +87,36 @@ $(selectors.testLatencyResponse).html(latency); } + function getDevicesHandler(evt) { + var jsFunction = "JK.GetASIODevicesResponse"; + logger.debug("About to try and call jamClient.GetASIODevices. Here's full jamClient:"); + logger.debug(context.jamClient); + context.jamClient.GetASIODevices(jsFunction); + } + + function GetASIODevicesResponse(response) { + $(selectors.getDevices + ' textarea').val(JSON.stringify(response)); + } + function events() { $(selectors.cSession + ' input[type="button"]').click(createSessionHandler); $(selectors.jSession + ' input[type="button"]').click(joinSessionHandler); $(selectors.testLatency + ' input[type="button"]').click(testLatencyHandler); + $(selectors.getDevices + ' input[type="button"]').click(getDevicesHandler); } function initialize() { var screenBindings = { 'afterShow': afterShow }; app.bindScreen('testBridge', screenBindings); events(); + app.subscribe(context.JK.MessageType.LOGIN_ACK, loggedIn); } // Public this.initialize = initialize; context.JK.TestBridgeLatencyResponse = latencyResponse; + context.JK.GetASIODevicesResponse = GetASIODevicesResponse; }; diff --git a/app/views/clients/_createSession.html.erb b/app/views/clients/_createSession.html.erb index 9571b3dc6..c7cf9a556 100644 --- a/app/views/clients/_createSession.html.erb +++ b/app/views/clients/_createSession.html.erb @@ -1,8 +1,8 @@