Getting error when leaving room on OnDestroy (Unity)

When the game object gets destroyed that holds the game room, I call room.Leave()

    public void OnDestroy()
    {
        if (isRoomJoined)
        {
            this.Leave();
        }
    }

This throws an error whenever I do this though.

WebsocketSharp Error! An exception has occured while OnClose.

Is the issue that I'm leaving while the gameObject is being destroyed?

Edit:

Also, it appears that this doesn't have any actual affect on any other rooms and everything appears to be functioning normally. But it scares me for it to have this error popping up.

Update:

When I try to just leave the room without destroying the game object, I still see the issue

So it looks like the error is coming from this cast of WebSocket to Room.
But I'm still not quite sure how to fix the issue.

0_1529542860133_Screen Shot 2018-06-20 at 5.59.57 PM.png

If I change this line in Room.cs it makes it work:
0_1529543210037_Screen Shot 2018-06-20 at 6.06.39 PM.png

@endel , does this change seem appropriate? If so, I could make a pull request for this change.

Hi @imallic, absolutely. I'll gladly merge this change. Thanks for sharing.