I''m programming an application in which 2 users share the same environment over a network / isdn link. I am using directplay for the communication.
As a first step I have got something working using IPX. One PC runs as the server and the other a client which joins it. I am trying to pass player position and orientation between the two machines.
PC 1 will tx player data to PC 2 and PC 2 will update according to the data received straight away. However, PC 2''s data does not seem to tx at the same time. It takes a while for PC 1 to pick this data up and move the ''remote'' player.
The reason I have labelled the 2 PC''s - PC 1 and PC 2, is that it doesn''t matter which one is the server and which one is the client. It''s always the same PC that exhibits the problem! (Sorry if all this confuses you!).
I''m using Dp->Send() and Dp->Receive() calls to tx and rx the data.
I thought it might be that one machine is hogging the network and not letting the other tx, so I tried to send the data every other frame to ease the congestion. This seems to help a little, but is not an ideal solution.
Is this the problem? Can you suggest of a ''neat'' way of doing things?
Sorry if all this is vague! If you need source code snippets, etc. Please let me know!
FYI, I am running it on a LAN between 2 PC''s. When it works, I would like to try it over an ISDN / modem link between the two.
Any help would be most appreciated!
First, is the application running in a server/client mode? Default is a peer-to-peer mode, which in most cases is the best way (especially in sessions with only two players). Note: the session host is not the same thing as the server.
Are you sending some information instantly, like a keepalive signal? That may cause a backlog in the network (which can be solved by using message throttling though).
This is how my message loop looks like (I use VB):
========================== Do Loop
Do While DPlay.MessageQueue() <> 0 GetMessage ProccessMessageData Loop
I.e. I first check if the messagequeue is empty, if not, get the message and process the data. Then I let the mainloop sleep a little (it checks for new messages every 100 ms). Just be careful how fast you send the data from the other player.
After reading other peoples posts and yours, I''ve realised I''m transmitting too much. ie. I transmit the player position and orientation every frame on both machines. It seems that the solution is (as you have also pointed out) to transmit every now and again.
In other words only transmit data say every 10 frames and only if the player has moved. I''ve tried a quick test with this and transmit every 10 frames and this solves the problem. However, the player movement on the other machine is jerky obviously. I suppose I now have to interpolate the players movements in between.