I'm using Raknet in my program and it's coming along very nicely. I've just started doing some multiplayer testing with several clients and have noticed some errors, due to my newbie programming behaviour, so I'd appreciate any help here.
Here's basically what's happening. When a packet comes in from a client and the server just needs to respond to it, it all works fine, because I can just take the client connection from the packet and respond to that connection.......
But sometimes I need my server to send out signals to connected clients based on various events that have happened. In these cases, the server doesn't have access to a packet, so it can't get the connection from a packet. To solve this (I'm sure there's an easier way), when the client first connects, I stored it's connection data in it's type, using the command......
p\Connection=RN_PacketGetPlayerID(packet)
So later on, when I need to send anything to that client without a packet to respond to, I send it with a line such as ......
RN_ServerSend2(Server,BitStreamOut,HIGH_PRIORITY,RELIABLE,0,P\Connection,False)
Unfortunately, this doesn't work. It seems to be sending the messages out to the wrong clients or something because it's all becoming garbled at the client end.
Is this the best way of achieving this? Is the original line for storing the connection correct?
Any help from Raknet users would be much appreciated :)
Here's basically what's happening. When a packet comes in from a client and the server just needs to respond to it, it all works fine, because I can just take the client connection from the packet and respond to that connection.......
But sometimes I need my server to send out signals to connected clients based on various events that have happened. In these cases, the server doesn't have access to a packet, so it can't get the connection from a packet. To solve this (I'm sure there's an easier way), when the client first connects, I stored it's connection data in it's type, using the command......
p\Connection=RN_PacketGetPlayerID(packet)
So later on, when I need to send anything to that client without a packet to respond to, I send it with a line such as ......
RN_ServerSend2(Server,BitStreamOut,HIGH_PRIORITY,RELIABLE,0,P\Connection,False)
Unfortunately, this doesn't work. It seems to be sending the messages out to the wrong clients or something because it's all becoming garbled at the client end.
Is this the best way of achieving this? Is the original line for storing the connection correct?
Any help from Raknet users would be much appreciated :)