How can i properly disconnect a client from a server?

Hi there!
My name is julian kaulitzki and i am working for the game project pantropy. I am working with bolt for quite some time now and the problem is that i do not know hot to properly disconnect a client from a server.
I saw inside of the API documentation that you can disconnect every client using the BoltConnection.Disconnect Method but i want to disconnect just one client. And that is when he is leaving the game.

Best regards Julian Kaulitzki


  • Call connection.disconnect() on their specific connection
  • what is connection? is it a BOltConnection? and if so does it not requiere a reference to anything?
  • i am really thankful for your quick response but ive already looked there and found nothing helpful just how to terminate all connections with:

    foreach(var connection in BoltNetwork.connections) {
    and i do not understand how i am able to disconnect just the one client who is trying to leave...
    I mean how am i able to call connectioon.Disconnect() if there is no reference to connection?

    cheers Julian Kaulitzki
  • If you are more specific I can tell you how I would implement it. How is the client telling the host it wants to leave?
  • edited May 2016
    alright, so the client has a panel and he can click on a button > "disconnect from server" he then returns back to the main menu. The button is hooked up with a disconnect method inside a script and all i need to know is how the code must look like inside of this function.
  • When you are processing the connection, cache it for whatever is being instantiated. You'll have easy access to the connection.

    I think there's a built-in object, but it was created after I started doing this so I don't use it.

    I *think* it's BoltEntity.controller tho BoltEntity.source might work too.

    I just find it easier that when you connect, just cache the connection since it's already there during the GlobalEventListener Connected (BoltConnection connection) event.
  • @JulianKaulitzki I'm going to assume you want the button to send an event to the host. When the host receives the event in server callbacks, call BoltConnection.Disconnection on Event.RaisedBy
  • edited May 2016
    thank you! i will try to cache the boltConnection inside of the OnConnected function and then hook the connection.Disconnect() to my button.

    @stanchion mod yes if this is the right way to do this then i would use your solution!
    SO the way you suggest it is by doing the following:

    evnt.RaisedBy.Disconnect(); ?

    sounds actually really simple

    just like that am i right?

    if(evnt.Disconnect && BoltNetwork.isServer)
  • edited May 2018
    Is there a way to Disconnect from the server without sending an event?

    edit: What about calling BoltLauncher.Shutdown() from clientside?
  • I saw and use this on the client
Sign In or Register to comment.