How to handle packets

Started by
0 comments, last by Lord Maz 21 years, 2 months ago
Hi, I''m new to network programming and when I tried to implement a multiplayer mode for my project, I got some problems. I can send packets and all that works great, but I''m not sure how to handle the packets and when to send them.. The problem was first when I sent packets every time a object moved, but since the movement happends very often (you move the objects with the mouse) it gets shaky. I tried to remedy this by constraining the number of packets sent, only one packet every t seconds (t is about 0.05), and when recived I move the object gradually from its current position to the new one over the time t. This works pretty well, but I''d prefer a less ugly method that (for example) doesn''t rely on hardcoded timers.. Anyone with experience who can tell me how to do it the best way possible? Thanks for any help! -Lord Maz-
-Lord Maz-
Advertisement
... so make the timer configurable

Seriously though, you may be overcomplicating things. The approach of sending on movement, but throttling to a certain rate seems just fine for the time being. Just make sure that the code is structured so that if you do find out that the current method doesn''t scale later, you will be able to change it easily.

cu,
Prefect
Widelands - laid back, free software strategy

This topic is closed to new replies.

Advertisement