hengineer / CaptainsMess

A local multiplayer networking library for making games like Spaceteam in Unity
MIT License
184 stars 21 forks source link

CaptainsMess does not recover from a temporary connection loss #7

Closed Nestorferrando closed 7 years ago

Nestorferrando commented 7 years ago

Hi! I found that if wifi connection is lost while CaptainsMess is finding a server or the game already started, the following message appears after disconnecting and trying to connect again.

By some reason host doesn't have broadcast addreses UnityEngine.Networking.NetworkDiscovery:StartAsServer() CaptainsMessServer:RestartBroadcastInternal() (at Assets/CaptainsMess/CaptainsMessServer.cs:106)

This can be reproduced easily in the ExampleScene by:

  1. Load ExampleScene
  2. Press autoconnect
  3. Disconnect wifi
  4. Press Cancel
  5. Reconnect wifi.
  6. Press autoconnect

I found a solution here here: http://forum.unity3d.com/threads/broadcast-discovery-already-running-startbroadcast-failed-err-8-startserver-listen-failed.357852/

adding a NetworkTransport.Init(); at the beginning of CaptainsMessNetworkManager.AutoConnect() and NetworkTransport.Shutdown(); at the end of CaptainsMessNetworkManager.Cancel() solves the issue.

Cheers Néstor.

hengineer commented 7 years ago

I added this fix in version 0.5. Thanks!