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

[bug] IsNetworkInitialized breaks if checked before _net set #76

Closed
sayangel opened this issue Feb 11, 2018 · 2 comments
Closed

[bug] IsNetworkInitialized breaks if checked before _net set #76

sayangel opened this issue Feb 11, 2018 · 2 comments

Comments

@sayangel
Copy link

sayangel commented Feb 11, 2018

Context

Checking IsNetworkInitialized before _net has been set by the Start() function results in error. I am calling it from a listener on Rooms.JoinedRoom, but Dissonance doesn't seem to be fully initialized.

Expected Behavior

If _net is not set IsNetworkInitialized should return false.

Actual Behavior

NullReferenceException: Object reference not set to an instance of an object
Dissonance.DissonanceComms.get_IsNetworkInitialized () (at Assets/Plugins/Dissonance/DissonanceComms.cs:198)

Workaround

Check IsNetworkInitialized on the next frame to ensure existence of _net in Dissonance instance.

Fix

Current Code:

      public bool IsNetworkInitialized
        {
            get { return _net.Status == ConnectionStatus.Connected; }
        }

Fix:

      public bool IsNetworkInitialized
        {
            get { return _net != null && _net.Status == ConnectionStatus.Connected; }
        }
@martindevans
Copy link
Member

Hi sayangel, thanks for the excellent bug report 👍

Your workaround is exactly right. I've also added checks to VoiceBroadcastTrigger and VoiceReceiptTrigger so that they will not do anything until DissonanceComms:Start has been called, to make things a bit neater in the most common path. That should be included in the next version of Dissonance.

@martindevans
Copy link
Member

Dissonance 6.1.0 just released onto the asset store with a fix for this. I'll close the issue but please don't hesitate to re-open it if it's still a problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants