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

Reduce reliance on fields (e.g., _deviceId) #16

Open
erodewald opened this issue Oct 4, 2018 · 0 comments
Open

Reduce reliance on fields (e.g., _deviceId) #16

erodewald opened this issue Oct 4, 2018 · 0 comments

Comments

@erodewald
Copy link
Contributor

erodewald commented Oct 4, 2018

I ran across an issue where the library would not work for my app which actually supports housing multiple users.

My app operates in a stateless manner, with configuration values passed between steps. Initiating pairing being one step - however 10 users could have initiated pairing through the same app instance before the original user has moved to the next step (entering their pairing code/pin). Unfortunately, the library leverages fields to pass those values around (_deviceId, _deviceName, _pairingRequestToken). I got around it by modifying a few functions.

@@ -114,12 +114,12 @@ let SMARTCAST = function smartcast(host, authKey) {
          * @param {string} pin The PIN displayed on the smartcast device
          * @return {Observable}
          */
-        pair: (pin) => {
+        pair: (pin, deviceId, pairingRequestToken) => {
             let data = {
-                DEVICE_ID: _deviceId,
+                DEVICE_ID: deviceId || _deviceId,
                 CHALLENGE_TYPE: 1,
                 RESPONSE_VALUE: pin,
-                PAIRING_REQ_TOKEN: _pairingRequestToken
+                PAIRING_REQ_TOKEN: pairingRequestToken || _pairingRequestToken
             };
             return sendRequest('put', host + '/pairing/pair', null, data).then((data) => {
                 if (data && data.STATUS.RESULT === 'SUCCESS') {

They remain optional, in the event that (most people) aren't going to need this functionality. It's kind of a band-aid, let me know what you think.

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

No branches or pull requests

1 participant