Adam's Lair Forum

game development and casual madness
It is currently 2017/04/30, 20:40

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 2016/07/09, 23:11 
Newbie
Newbie
User avatar

Joined: 2016/07/09, 17:28
Posts: 8
Role: Hobbyist
Hello everyone,

My name is Elfocrash and ever since i discovered Duality i really liked the job Adam has done.
I saw this demand from the users of a solid networking system.
Adam said himself that it is not one of his priorities so I think I can help.

The only solutions i saw around is some synchronous symbol separated solutions :'(
fully single threaded and synchronous, so really there is not a solid solution out there.

So i preset your *drum roll* DualityNet! (What an original and creative name)

DualityNet is here to solve all your multiplayer problems and offer a solid packet based
solution for networking.

General games networking.

As you may or may not know in almost every game the server and the client communicate
with each other using packets.

A packet is basically a byte array of data constructed in a specific structure.
A packet with structure cSdd is a packet that consists of those datatypes in this very
specific order: byte,String,Int,Int.

If the client sends a packet like this to the server then the server will read the first byte,
called the OpCode, which is a unique identifier for this specific packet and then the server
knows exactly with which sequence it needs to read this packet and do stuff.
Same for the server to client packet.

How does DualityNet work?

Exactly like the example i showed you above.
DualityNet consists of a gameserver and the client hook.
The gameserver is your backend that will receive the client packets and send the info to
the client and the hook is how the user will read and set packets.

Here is all you have to do to enable DualityNet on your CorePlugin:
Image

And that's literally all you have to do to hook your functionality to the client.

The other side of things is also pretty minimal. You have a never ending console application
which has the role of the gameserver.

It looks like this:
Image

All you have to do is run it.
The gameserver is fully asynchronous.
The client side is synchronous.

ClientPackets/ServerPacket

Client packets are the packets that the client will send to the server.
Server packets are the packets that the server will send to the client.

Here is what they look like:
Image

Client packet to the right and the response to this packet to the left.

The packet handler will check the opcode and decide which client packet is which and
run it:
Image

How do I write my own packets?

Client packets
Client packets are usually ones that request something from the server or inform it for something.
That get the data from the client and they send it over to the server.
A packet is constructed by many different datatypes converted in a byte array.
Here is how you read a movement validation clientpacket:
Image

Server packets
Server packets are the ones the server sends to the client.
I will use the same example as above and i will show how we would create this movement
validation packet as the server this time.
The reason for this packet could be to validate the users initial position after a restart
setting him again in his previous location.

Image

See the structure? Always the opcode to identity the packet and then whatever you want.

Sending and receiving the packets
I won't bore you with networking stuff so i will just give you the answer.

Sending a client packet:
Image

Receiving a client packet:
Image


Famous last words
It is not quite finished yet but i will post the public github repo so you can fork and contribute if you want or just track the progress.

Please leave a comment with your feedback and suggestions.

Github repo: https://github.com/Elfocrash/DualityNet

Space stuff Multiplayer Test


Thanks,
Elfocrash


Last edited by Elfocrash on 2016/07/10, 21:15, edited 2 times in total.

Top
 Profile  
 
PostPosted: 2016/07/10, 11:40 
Forum Adept
Forum Adept

Joined: 2015/07/08, 16:41
Posts: 414
Role: Gamer
Damn, that looks pretty good. Great work!


Top
 Profile  
 
PostPosted: 2016/07/10, 12:32 
Newbie
Newbie
User avatar

Joined: 2016/07/09, 17:28
Posts: 8
Role: Hobbyist
Thanks a lot.

I might have to update some of the pictures because i completely separated the packet handling on client and on server.

I will probably make a small example too with a realistic scenario.


Top
 Profile  
 
PostPosted: 2016/07/10, 14:51 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1949
Location: Germany
Role: Professional
That does look interesting. I like the rather low-level approach you're taking here. Looking forward to a sample game for this! Maybe network Pong? Or, for something more complex, multiplayer Asteroids?

Is there a specific reason for user-defined packets being classes although your internal, raw Packet is (which I suspect is a good decision) a struct?

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2016/07/10, 14:58 
Newbie
Newbie
User avatar

Joined: 2016/07/09, 17:28
Posts: 8
Role: Hobbyist
Mainly because people don't quite understand structs (from personal experience) so i thought i'd rather keep the things that users might wanna add themselves more familiar to what they know.

I might create a MMO Rpg demo but my main problem is i don't know how i can have a textbox for login credentials xD


Top
 Profile  
 
PostPosted: 2016/07/10, 15:06 
Junior Member
Junior Member
User avatar

Joined: 2016/03/02, 04:35
Posts: 48
Role: Observer
That indeed looks solid, good job! Looking forward to see a demo so I can take a look on how it works.

Quote:
I might create a MMO Rpg demo but my main problem is i don't know how i can have a textbox for login credentials xD

I lol'd, c'mon. :mrgreen:


Top
 Profile  
 
PostPosted: 2016/07/10, 15:17 
Forum Adept
Forum Adept

Joined: 2015/07/08, 16:41
Posts: 414
Role: Gamer
Elfocrash wrote:
I might create a MMO Rpg demo but my main problem is i don't know how i can have a textbox for login credentials xD
You can get the character input that was typed since the last update by using Duality.DualityApp.Keyboard.CharInput. I think that might be what you're looking for. Though I imagine you'd need to make your own textbox, make the password look like asterisks etc. on your own.


Top
 Profile  
 
PostPosted: 2016/07/10, 15:50 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1949
Location: Germany
Role: Professional
By the way, I'm moving this topic to the Projects forum, I think it fits better over there.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2016/07/10, 15:51 
Newbie
Newbie
User avatar

Joined: 2016/07/09, 17:28
Posts: 8
Role: Hobbyist
Adam wrote:
By the way, I'm moving this topic to the Projects forum, I think it fits better over there.


Yeah sure np :)


Top
 Profile  
 
PostPosted: 2016/07/10, 19:18 
Newbie
Newbie
User avatar

Joined: 2016/07/09, 17:28
Posts: 8
Role: Hobbyist
Yeap, im onto something :)

Only some movement related stuff to figure out and it should be good to go.

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group