Jump to content
  • Advertisement
Sign in to follow this  
Nalda

Identifying received data on server & server method calls

This topic is 400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, after 2 days of unfruitful researching, I finally sell my soul and ask for once

I'm just starting out in socket programming (C#)
All I managed to do for now is calling a method with BeginReceive and its async callback parameter.

What I'm trying to get my head around, is, how do you actually call a specific method depening on the data received ?

Note that I didn't get any further yet than just displaying the received bytes as a string.

Share this post


Link to post
Share on other sites
Advertisement

you need to decide what the data in the packet means to your game.  the format of the packet.  you will want something like that first byte being an identifier for what kind of data follows.  then based on the byte you know what to do with the rest of the data in the packet.

 

i.e.

the first byte is a 0 which means it is a chat message.  you then read out the next bytes that represent the message and then display that message on the screen.

the first byte is a 1 which means it is a position update message.  you then read out the next bytes that represent an object id and position.  you then move the object with the id and set its position.

the first byte is a 2 which means is a "fire ze missiles" message.  you then read out the next bytes that represent the id of the object that fired the missile, the start position of the missile, and the vector of its movement.  you then call your method to add a new missile to your game.

etc....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!