Skip to main content
gamedev.net
🔒 Locked

Designing a protocol

Started by Ironica 7 replies 800+ views
Original Post
Ironica
Ironica
Hey guys, was just thinking about how I would write the communication between my game server and client. Haven''t quite got to it yet (not far off), but I was just hoping for some general tips. Any good tutorials around on the subject? I''d love to see some examples, because I always get the feeling my code is lousy =/ hehe. I often find comparing my code to someone else''s makes me feel so bad, that I just start over. I''m quite tempted to go sniffing around other game servers, and see what their protocols are like. Anyone got anything I might like to see?
krez
krez
general tip: include only what you have to, so the messages are as small as possible without leaving things out.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
fingh
fingh
You should find a game that is in the same genre as what you wish to create (fps, MMO, rts etc). Then figure out the protocol they are using. It''s actually not too tough, as very few games use encryption or real compression for data packets.

Good luck.
KalvinB
KalvinB
My current project uses 2 general types of messages

Both use the same header with the following information

message type number
message length
message data

type number 1 is a text message which has two types

if byte 0 is a ''.'' then it''s a command (like MUDs use) otherwise it''s a plain text message.

if the type number is greater than 1 then it''s also a command but one that doesn''t use plain text

for instance you can send message type 1 with message data ".earthquake 5 6" with the length as the length of the string to set off an earthquake at location 5,6 or send message type 40 with a length of 2 and data[0]=5 and data[1]=6

The basic idea is that you don''t make your message struct specific. What you need to send should be converted into bytes, stuffed into a generic struct like the above and then sent.

Then you just have both sides use a switch(message.type) to interpret the incomming data.

You want to then try to minimize the number of message types you need to have. And that depends on your game.

The advantage of setting up a MUD like system on top of the byte code system is to make testing things far easier. I don''t need to make a button every time I add some new feature. I can just send a plain text dot command to make sure it works. Then tie it into the engine with the byte code version as well.

Ben


IcarusIndie.com


recycledrussianbrides.com



KalvinB - (to Jessika) do you accept Jesus as your lord and savior

Jessika - Sure I can accept all forms of payment.
Ironica
Ironica
Excellent. Thanks for the replies.

KalvinB, could you show me how your message headers look? What you said sounds simple enough though.

I hate asking stupid questions, but what''s a MUD? Sorry, my lifelong dream is to be a game programmer, but I have never learned anything about it =( I''m just putting what I do know to the test, hehe. I haven''t even learned to use DirectX or OpenGL >.< I cross that bridge when I come to it =)

P.S. My game is intended to be an MMORPG =)
cmptrgear
cmptrgear
MUD=Multi User Dungeon


"I may not agree with what you say but I will defend to the death your right to say it."
--Voltaire
"Pfft, Facts! Facts can be used to prove anything!" -- Homer J. Simpson
Ironica
Ironica
Ahh thanks. I guessed the M and U >.<
lexa
lexa
Hello,
i am Lexa Yo, my friend and i have just finished the first version of a game engine wich should become an MMORPG. You can see the article i have posted :

http://www.gamedev.net/community/forums/topic.asp?topic_id=165920

our games run in realtime, with a lag that is very good since our server is in Paris (France), and the adsl is quite slow.

our com. protocol is very simple. we have defined what we need and group fonctionalities in commands. For exemple we have a "CreateObject", an "SetObjectState"... wich have a variable list of parameters.

The data sent is a melt of bytes and strings.

i hope it will help, bye,

Lexa.

PS : you have my e mail on the site explained in the post
Yo!
lexa
lexa
Hello,

i am Lexa Yo, my friend and i have just finished the first version of a game engine wich should become an MMORPG.

You can see the article i have posted about it :
http://www.gamedev.net/community/forums/topic.asp?topic_id=165920
or try it now :
http://www.hublot.org

our games run in realtime, with a lag that is very good since our server is in Paris (France), and our adsl is slow.

our com. protocol is very simple. we have defined what we need and group fonctionalities in commands. For exemple we have a "CreateObject", an "SetObjectState"... wich have a variable list of parameters.

The data sent is a melt of bytes and strings.

i hope it will help, bye,

Lexa.

PS : you have my e mail on the site
The site is in French for now (it is being traduced) but it is simple to play :

1- type your login and choose your character (no enter after login).

2- Use [mouse] to move and [Space Bar] to shoot.

3- Walk thru the rooms and chat (just type text and press enter while playing).

4- Press [ctrl] when you are on teletransporters to launch a game. Then wait for some people to lock beside you. Then fight to survive.


Sorry for those who have a firewall, it doesn't work yet



[edited by - lexa on July 13, 2003 8:33:16 PM]
Yo!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.