kstzl / UrsinaNetworking

A High level api to do networking with the Ursina Engine
https://pypi.org/project/UrsinaNetworking/
MIT License
67 stars 14 forks source link

Make server kick client #15

Open JulenRa-dev opened 6 days ago

JulenRa-dev commented 6 days ago

.Is there some way to make the server kick a client? For example, something like for client in server.get_clients(): if client.toofast: server.kick_client(client)

CodeEzpro commented 5 days ago

You can send a message to the client to shut down process_net_event Server :

def kick(client,reason):
     client.send_message("kick",reason) # Send a message containing "kick" with content reason

Client :

# Your code, imports, definitions etc

kick=False
@Client.event
def kick(reason):
    global kick 
    kick = True
    print(reason) # you can add a reason if you want. If not replace the reason variable on the server to any value you want

while kick=False:
    Client.process_net_event()
   # Other stuff