Networking Player Management Help

After reading the documentation in the manual I have created a simple server and client. I now want my server to tell the other clients when a new client has connected and tell the new client about the current clients connected. Any help would be greatly appreciated as my networking knowledge in panda3D is limited to the documentation.

Are you using Panda’s DO system?

Will assume you are and if that’s the case you can either build the method to be zone-specific or global. Global would have to be handled by a Repo that has an interest in all zoneIds … so either the Server Repository or the Repo running your TimeManagerAI (if you’re using DSN). Zone-specific can be as simple as adding text whenever a specific distributed object is received by a client’s repository (created at the time when your setZoneInterests match up).

If you’re not using the DO system that probably sounds like a lot of gibberish.

Edited to add: You could create a new message type or use an existing one as well. Always forget about those.

I am currently not using the DO system as it is not fully documented yet so I really have know Idea how to set it up or how it works. I was thinking that my server could store clients by IP and then send a message to a new client what those ips are and there current location. The problem is I don’t know how the server can keep track of the ips and then send them to new clients.

Thanks for your help.

Easiest way to keep track of something like that would be to use a dict.

connectedClients[id] = socket_information

All depends on the scheme you are developing to update clients. Panda’s DO system uses something similar.

So Clistener would add newConnection + a number and then tell the other clients of that ID. Then the clients would create a new object if the ID were new.

When your server receive a new connection. Append his info in a dict as explained in the manual and (for your case) implement a variable to know the number of current connectiono or use len(yourDict).
After that, send to all connected clients the information of the new person you just added to your dict, something like:

myPyDatagram = PyDatagram()
myPyDatagram.addString('MyFirstInfo')
myPyDatagram.addString('MySecondInfo')
for client in dict.sourceOfMessage: self.cWriter.send(myPyDatagram, client)

Ok after doing some researching and looking at the example created by drwr and zanz I now understand the basics of the DO system. One question how would I be able send a ray-cast that hits another play which tells them they were killed.

Thanks for the help that was what I needed help with. Thanks very much.