Skip to content

Temporarily Blocking Connections

Balroth edited this page May 8, 2019 · 2 revisions

Sometimes, when a match starts, you don't want people being able to join the server, even when other players leave. You are able to tell the server to no longer accept connections as seen below:

NetWorker server = new UdpServer(32);
server.Connect();

// ...

// Don't allow any more connections to this server, but don't kick any current connections
((IServer)server).StopAcceptingConnections();

Obviously we needed to give you a way to be able to start accepting connections again otherwise that would be kinda rude. So we went ahead and made the following function for you to begin accepting connections again. Note that this is a continuation of the above example

// Start allowing for connections to this server again
((IServer)server).StartAcceptingConnections();

Lastly, you may have forgotten or don't know if you stopped allowing connections, so we made this handy boolean for you to check against! Note that this is a continuation of the above example

if (!((IServer)server).AcceptingConnections)
{
    // Connections are currently not allowed for this server
}

Home

Getting Started
Network Contract Wizard (NCW)
Network Object
Remote Procedure Calls (RPCs)
Unity Integration
Basic Network Samples
Scene Navigation
NetWorker
Master Server
Web Server
Netcoding Design Patterns
Troubleshooting
Miscellaneous
Clone this wiki locally
You can’t perform that action at this time.