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

unable to send message when using easyrtc with audio #77

Closed
rrrepos opened this issue Jan 6, 2018 · 3 comments
Closed

unable to send message when using easyrtc with audio #77

rrrepos opened this issue Jan 6, 2018 · 3 comments

Comments

@rrrepos
Copy link

rrrepos commented Jan 6, 2018

This does not happen always. But frequent enough to cause concern in a production environment. The error that shows up in the javascript console is:

attempt to send message without a valid connection to the server. The debugger shows that it is from: chrome://devtools/content/webconsole/src/utils/index.js. This is even when it is run in Firefox.

The only way forward seems to be to exit the scene and reload it. And it always works then.

@haydenjameslee
Copy link
Collaborator

Are you sending any custom messages (using the custom message API) or running any network code before the onConnect function has been called?

@rrrepos
Copy link
Author

rrrepos commented Jan 7, 2018

Yes. In the scene I need to keep track of the position of the user. I internally call it marker. Think of it as the seat where the user is. And the following is the onConnect code.

onConnect: function() {
      // storing this users id
      _this.clientId = NAF.clientId;

      // updating marker of user
      NAF.connection.subscribeToDataChannel("marker", function(senderId, datatype, data) {

        var userIndex = _this.usersArr.indexOf(senderId);
        if (userIndex == -1) {
          _this.usersArr.push(senderId);
          _this.markersArr.push(data);
        } else {
          _this.markersArr[userIndex] = data;
        }
      });

      // adding to array when new user enters scene
      document.body.addEventListener("clientConnected", function(evt) {
        var userIndex = _this.usersArr.indexOf(evt.detail.clientId);
        if (userIndex == -1) {
          _this.usersArr.push(evt.detail.clientId);
          _this.markersArr.push("");
        } else {
          _this.markersArr[userIndex] = "";
        }
        NAF.connection.sendDataGuaranteed(evt.detail.clientId, "marker", _this.curr_marker)
      });

      // removing from array when user exits scene
      document.body.addEventListener("clientDisconnected", function(evt) {
        var userIndex = _this.usersArr.indexOf(evt.detail.clientId);
        if (userIndex != -1) {
          _this.usersArr.splice(userIndex, 1);
          _this.markersArr.splice(userIndex, 1);
        }
      });
    },

And somewhere else when the user decides to move via an event trigger, the following is broadcast: NAF.connection.broadcastDataGuaranteed("marker", _this.curr_marker);

@vincentfretin
Copy link
Member

It's quite old. I'm just going to close it. Please reopen if you still have the issue with open-easyrtc. See #240

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

3 participants