- Home /
NetworkServer.dontListen not working - How do I stop clients connecting?
I'm currently on Unity 5.3.2f1 and have been using NetworkServer and NetworkClient to add multiplayer to the game I'm currently working on. I haven't and will not be using NetworkManager at all, favouring making my own version of a manager because it suits our game better which is turn based and two years in the making! (Trust me, it was easier.)
Using NetworkServer.Configure I have constrained the max number of connected clients to 9. Thus I only allow 9 lobby slots. When a client connects he is automatically assigned a player to one of those lobby slots, however he also has the ability to add another player which he can control to another lobby slot. This means I have one less slot available for connecting clients.
According to the documentation, by setting NetworkServer.dontListen to true, the host will stop listening for new connecting clients, which I assume means it will not allow no one new to connect. So, when I have all my lobby slots full I enable dontListen. Unfortunately, when I attempt to connect another client, he succeeds.
Does NetworkServer.dontListen work/not work for anyone else? Is there another call I have to make? Or is the flag being set incorrectly?? Or does dontListen not mean don't allow new clients to connect, and if so.. how do I do that?!
Same for me. I want to block inco$$anonymous$$g connections but it's not working...
Answer by shadiradio · Sep 12, 2016 at 07:19 PM
I've found that it only works (for me) if you set it before starting up the host, which sort of defeats the purpose of it. I have a similar situation to what you described and this is incredibly frustrating. If the server is already running, this flag doesn't seem to do anything. :(