[ENet-discuss] Object unique ID's

Bjørn Lindeijer bjorn at lindeijer.nl
Mon Mar 17 04:21:59 PDT 2008


Ruud van Gaal wrote:
> Hi Martin,
> 
> Thanks for that. Indeed your method is what I attempt to do. The only thing
> left is to determine which client actually owns the car after the new-car
> message comes in. The flow:
> 
> - client1 requests car
> - server accepts, sends newCar message (with unique car.NetworkID) to all
> clients
> - client1 sees the newCar message and creates the car
> 
> Now how does client1 know that it's his car and not a car from another
> client? A useful method then would be if clients also had an ID that would
> be the same on each computer. That way you can say 'newCar with networkID
> <x> and ownerClient <y>' which would work on all clients.
> You'd need the following (I really think I'll add that to ENet):
> - server starts
> - client attempts connect to server
> - server generates unique ID for client and replies connectOK with uniqueID
> 
> If this happens in connection phase (inside ENet) that would help in
> debugging connections.
> 
> How would you determine whether the car just generated was owned by the
> requesting client?

I really don't see why you couldn't just have the server create and send 
the ID right after ENet set up the connection.

As for solving the problem without having to set up client IDs, what 
about sending the client that requested the car a single additional 
message telling him his car ID?

- client1 requests car
- server creates car
- server sends carRequestReply to client1 with its car ID
- client1 stores this ID locally
- server sends newCar message to all clients
- client1 compares the car ID to the ID it knows as its own car

If you want to avoid having to remember the variable, you might as well 
just have a yourNewChar message in addition to the newCar message, and 
send that to client1 instead of the newChar message.

Regards,
Bjørn


More information about the ENet-discuss mailing list