MaGNet - GNet extension.

BlitzMax Forums/BlitzMax Programming/MaGNet - GNet extension.

Mahan(Posted 2008) [#1]
I wanted to share what I've been playing with this weekend: An extension to GNet to be able to have network-replicated instances of BlitzMax objects with native fields (instead of the TGNetObject slots).

Lots of people on this forums seem interessted in network-programming so I desided to post it here for everyone to share. If you find bugs or make updates I'd be very glad if you could post it back here.

have fun! :)

MaGNet.bmx:


crc32.bmx:


magnetdemo.bmx (rewritten from siblys old gnetdemo):


To make the demo work:

1.) download www.blitzbasic.com/tmp/gnetdemo.zip (marks gnet demo)
2.) unzip it to a folder
3.) put all files from this post into the same folder as #2
4.) Build magnetdemo.bmx


edit: updates to sources and added example.
edit2: updated 20081205 - small error when creating remote object (internal). Added initial remote update that was missing.


Foolish(Posted 2008) [#2]
I'm getting a duplicate identifier error when I try to compile for the dx variable. Perhaps this has something to do with your "uncomment when not in BLide" which I don't understand.

I did uncomment the include statements to ensure they were available. Any thoughts?

It looks like variables like dx, dy, MSG, and value are used/reused repeatedly in the While loop.


Mahan(Posted 2008) [#3]
My misstake. I tried this out in my normal MaxIDE on my other computer and had to change two things:

1) Uncommented the Include "crc32.bmx" - line. (as you mentioned)
2) Added "SuperStrict" on top of magnetdemo.bmx

Code above is updated and now tested from within MaxIDE.

Just update you code and press F5 when your in magnetdemo.bmx in MaxIDE and everything should work.

Btw some instructions:

When started you steer the ship with arrow-keys and shoot with left-ALT

commands (just write them right in):


Open a server for incomming connections (do this on one of your test processes):
/listen


To act as a client and connect to the server:
/connect [servername]

The servername is optional (default is localhost and will work if you run this game twice on the same computer)

Change your name in the game:
/nick <new name>

And just write text (not preceded by a /-char) to chat with the other clients.

EDIT: Posted FP once again this time with import instead of include. (I get so Lazy when using BLIde.) Now all files are correctly compilable from within MaxIDE.


Foolish(Posted 2008) [#4]
Just did a quick test compiling through MaxIDE and it worked fine. I set up a server with two clients on the same machine.

I'll start playing around more seriously tonight and see what I find. Looks promising though.

A quick question though, what is the SLOT_TYPE = 0 used for?

Thanks much.


Mahan(Posted 2008) [#5]
SLOT_TYPE is an old remenant from the old code. When someone shoots you the client detects this and sends a "raw gnet message" (i.e. not through MaGNet) informing the remote client that shot you that it scored a point.

But still the demo shows how both the bullets and the players (TBullet and TPlayer respectively) are actually running through MaGNet and that they are "pure blitzmax objects" that are automagically replicated through the network. That was that point of the demo.

Its very possible to rewrite the hit-information into a MaGNet object to (just make another class that extends TNetGameObject) but since it wasn't neccessary for the demo i just didn't bother. (laziness) :)


Foolish(Posted 2008) [#6]
It definitely seems to meet the objective of simplifying things.

Plus, I did run it on two computers side by side on the ol' home network LAN and it seemed to work really well. Since I am more worried about LAN play, than internet play, this is well worth some more testing on my part.

I'll look to create my own test project over the next several days. Actually, I'll probably need the weekend to make real progress. When I get something together that adds to your example from a demo perspective, I'll be sure to post it.

Thanks again for your inspired re-examination of GNET. I think many of us may have been too quick to overlook it. I'm happy to dig back in.


Mahan(Posted 2008) [#7]
Thank you too for trying it out.

I wrote this for my own hobby-project "Maze Team" which is ment to be a very basic "instant dungeon" rpg for a few networked players. (idea: arm you char -> jump into dungeon action with friends.)

It's worth to mention that this code is "alpha state" just so you know that it probably contains several bugs, and I'll be checking this thread each day for a week or two in case someone reports bugs. And I'll be posting back updates to the first post in case I fix something. (I think from now on I'll add a date on the "edit" so everybody else can see if they got the latest version)

Now that BlitzMax got both reflection and threads (of which I am very pleased!) I expect we'll see other intressting rewrites or extensions of other modules. So whats next? BlitzMax on Rails? My point is: the limitation is not longer in the language. The limitation now is the imagination of us using it :)