XNET Multiplayer Netzwerk Modul (1.023r) [OPEN SOURCE]

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen

 

c64

Betreff: XNET Multiplayer Netzwerk Modul (1.023r) [OPEN SOURCE]

BeitragFr, Feb 20, 2009 18:56
Antworten mit Zitat
Benutzer-Profile anzeigen
user posted image

Hi,

Aus der Entäuschung über GNET wuchs mein verlangen nach einem eigenen immer wieder einsetzbaren MultiplayerNetzwerk Modul.

Wie schon im Worklog von HOLOCUBE erwähnt benutze ich BNETEX von Vertex für den Netzwerktransfer, das heisst also dieses Modul benötigt ihr auch.



XNET SOURCE Download(1.024r)

Sry. für die schlampige bis nicht vorhandene Doku!


Code: [AUSKLAPPEN]


Function XNETHostSession:TXnetSession (Port:Int)

Function XNETJoinSession:TXnetSession (IP:String,Port:Int)
         
Function XNETUpdateSession (Session:TXnetSession)

Function XNETCloseSession (Session:TXnetSession)



Function XNETObjectLocal:Byte (SessionObject:TXnetSessionObject)
         
Function XNETObjectRemote:Byte (SessionObject:TXnetSessionObject)

Function XNETGetObjects:TList (Session:TXnetSession)
               
Function XNETGetMessages:TList (Session:TXnetSession)



      
Function XNETCreateObject:TXnetSessionObject (Session:TXnetSession)
         


Function XNETSetByte (SessionObject:TXnetSessionObject,SlotID:Int,data:Byte)
         
Function XNETSetInt (SessionObject:TXnetSessionObject,SlotID:Int,data:Int)
         
Function XNETSetFloat (SessionObject:TXnetSessionObject,SlotID:Int,data:Float)
            
Function XNETSetDouble (SessionObject:TXnetSessionObject,SlotID:Int,data:Double)
                                             
Function XNETSetString (SessionObject:TXnetSessionObject,SlotID:Int,data:String)

         

Function XNETGetByte:Byte (SessionObject:TXnetSessionObject,SlotID:Int)
         
Function XNETGetInt:Int (SessionObject:TXnetSessionObject,SlotID:Int)
         
Function XNETGetFloat:Float (SessionObject:TXnetSessionObject,SlotID:Int)
            
Function XNETGetDouble:Double (SessionObject:TXnetSessionObject,SlotID:Int)
                                                                              
Function XNETGetString:String (SessionObject:TXnetSessionObject,SlotID:Int)



Function XNETSetTarget (SessionObject:TXnetSessionObject,TargetObject:Object)
         
Function XNETGetTarget:Object (SessionObject:TXnetSessionObject)


Function XNETCreateMessage:TXnetSessionObject (SenderObject:TXnetSessionObject)

Function XNETSendMessage (MSGObject:TXnetSessionObject,Receiver:TXnetSessionObject=Null)
         
Function XNETMessageObject:TXnetSessionObject (MSGObject:TXnetSessionObject)



Function TXNETConfigServerDialog (ServerURL:String,ScriptPath:String)

Function XNetGetHostList:TList ()

Function XNetRegisterHost:Byte (Session:TxnetSession)

Function TXNETHostSendAlive ()

  • Zuletzt bearbeitet von c64 am So, Nov 14, 2010 13:59, insgesamt 15-mal bearbeitet

Blackside

BeitragFr, Feb 20, 2009 23:10
Antworten mit Zitat
Benutzer-Profile anzeigen
Hört sich ja schonmal gut an Very Happy
Ich schaus mir nacher mal an
Hier sollte eigentlich eine Signatur stehen!
 

liver2009

BeitragSa, Feb 21, 2009 4:19
Antworten mit Zitat
Benutzer-Profile anzeigen
hi,this is nice,i plan to use this in my new project!!!
please keep up the good work!!! also if you need some
donation please tell me!!! Razz

translation:

Zitat:
hi, das ist schön, ich plane, diese in mein neues Projekt! Bitte bewahren Sie die gute Arbeit! auch, wenn Sie einige Spende Sagen Sie mir bitte! : P

ps:ist das TCP-oder UDP?
 

c64

Betreff: Hi,

BeitragSa, Feb 21, 2009 13:36
Antworten mit Zitat
Benutzer-Profile anzeigen
..

woOw Thx !!! ,if your Project is noncommercial use Xnet for free.
Donation?, yes of course allways Smile (Jst'a'jke) but atm. not possible. If your Project is commerziel you can buy a Lizenz for a litle Price.

TCP or UDP -

All Streams i use atm. are UDP streams from BnetEX, and the standard communication from XNET between Sessions are allways work with UDP. But i plan a extension to Register GameHosts, and get Registered GameHosts on a MainServer this will work with TCP but have nothing to do with the SessionCommunications.


Zitat:

woOw Danke !!! Wenn dein Project nicht kommerziel ist dann kannst du Xnet frei benutzen.
Spenden ? klar immer doch ("scherz ?!") ist aber im moment nicht möglich. Wenn dein Project kommerziel ist kannst du eine Lizenz kaufen für einen kleinen Betrag.

TCp or UDP -

Alle streams die ich im moment benutze sind UDP streams von BnetEX, und die standard kommunikation zwischen den Sessions arbeitet nur über UDP. Aber ich Plane noch eine erweiterung die es ermöglicht GameHosts auf einem Hauptserver zu registrieren und registrierte Hosts abzurufen. Dies hat allerdings nichts mit der eigentlichen Communication zwischen den Sessions zu tun.


mfg. C64
Betreten verboten! Kinder haften für ihre Eltern!
 

liver2009

BeitragSo, Feb 22, 2009 3:31
Antworten mit Zitat
Benutzer-Profile anzeigen
hi c64, glad that you can speak english and i need not to use
the machine translator again!!!

i am seeking for a nice network lib for a long time and at last i
use Gnet due to the easy functions.but Gnet uses Enet which
only support UDP!! Xnet is as easy as Gnet and also plan to support Tcp ,that exactly what i want. so i hope you will continue
to develop this lib,can't wait to see the Tcp part. if the lib is for
sale i will buy one license!!!

After some tests i got some problems:

1.would you please give some more details to use MessageObject?
2.in the example code,i am a little confused about this line:

----------------------------------------------------------------
Local MSGObject:TXNetSessionObject = XnetCreateMessage (Local_object1)

XNetSetInt (MSGObject,_slot_001,1) ' this line

XnetSendMessage (MSGObject)

-----------------------------------------------------------------
what is it for? it set the message object slot1 to value 1 and i can't
figure out when to read this value out in the latter function.when i
try to comment this line out the mousedown check will not work...



3.i can't send constant values to sessionobject slots,so if i change
the code like this:

Code: [AUSKLAPPEN]
local_object1.SetInt    (_slot_001 ,100)' change mousex to 100
local_object1.Setint    (_slot_002 ,100)'change mousex to 100


then on the client we will get two "0",the circle is at position(0,0).

if i change the code a little:
Code: [AUSKLAPPEN]

local_object1.SetInt    (_slot_001 ,101)'change mousex to 101 first
local_object1.SetInt    (_slot_001 ,100)'change mousex to 100
local_object1.Setint    (_slot_002 ,101)'change mousex to 101 first
local_object1.SetInt    (_slot_002 ,100)' change mousex to 100


now it works,so i think you add some code to check the value changes? only send the slot if the value in the slot changes?

sorry for my english too,i am from asia,i hope i made myself clear!
 

c64

Betreff: better Sample001

BeitragSo, Feb 22, 2009 10:55
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi liver2009,

My english is not very good too but it's good enough for a litle conversation i think.

The Tcp part is only to get Registered hosts it's only a extension for Xnet ! But this will be include to the current Modul at next time.

In the Example i don't read the messageSlot thats right, and i do only send modified slots thats right too.

But you found the trick to update every time, i do have write them yesterday in the Docfile of XNET.
You become it to work without the tip , nice !! Wink

But its not a bad idea to set a Flag for a slot i think, so that importent slots each time will be send (worst case) or send if a new Session login ( better ), i work on it !!

I have rewrite the Sample each action is marked with infos ! So i hope it's easier to understand it and XNET.

And now i use the MessageObject to send a Int and Read a Int ( i byte will be enough for this, but i have use a int ) , this will be use to send witch mousebutton is down.



Code: [AUSKLAPPEN]

'Sample 001
'----------

Import c64.xnet
SuperStrict

' Create a Sessionhandle and try to connect a session
'                        

Global  Local_Session:TxnetSession
      Local_session = XNETJoinSession   ("127.0.0.1",12345)
   If Local_Session AppTitle ="ClientSession :" + local_session._SessionID


' If local session not exitst it haven't Host also try a Join
'                        

   If Not Local_session
   local_session = XNETHostSession (12345)
   AppTitle ="HostSession"
   EndIf


' Set 2 Messages Slots for Objects

Global _slot_001:Byte = 1  ..
   , _slot_002:Byte = 2
                     

' Create a Local SessionObject (for a player or what ever you want)

Global Local_Object1:TXnetSessionObject
     local_Object1 = XNETCreateObject (local_session)
   


' No comment :)
                                 
Graphics( 600,200,0,100,2)

Global Timer:TTimer = CreateTimer (60)

Repeat

   Cls


   'Update the Local SessionObject to Receive and Send Data
   
   XNETUpdateSession (LOCAL_SESSION)
   

   
   If KeyHit (key_escape) End
   
   ReadSessionUpdates  ()
   SendSessionUpdates  ()
   DrawSessionInfos    ()
            
   
   

   Flip
   
   WaitTimer (timer)
   
Forever



   

      
Function ReadSessionUpdates ()

'Check Messages, if not incoming Messages this Loop will ignore

For Local Message:TXnetSessionObject=EachIn XNETGetMessages (Local_Session)

'Get Sender Object                           
Local Sender:TXnetSessionObject = XNETMessageObject (Message)

If sender
SetColor 0,255,0

   
   'Get the MessageData and choice by the Value a color
   
   Local MessageData:Int = XNETGetInt (Message,_slot_001)
      
   Select MessageData
      Case 1      SetColor 0,255,  0   
      Case 2      SetColor 0,  0,255   
   EndSelect
         
   'Get the 2 Slots (for position !) from sender NOT from the MESSAGE !!!

   Local X:Int = XNETGetInt (Sender,_slot_001)
   Local Y:Int = XNETGetInt (Sender,_slot_002)
   DrawOval X-15,y-15,30,30
   
EndIf
   
Next




'Check Objects and get the SlotData for position to draw a oval


For Local SessionObject:TXnetSessionObject=EachIn XNETGetObjects  (Local_Session)

If SessionObject._local=False

   SetColor 255,255,255



   'Get Slot Data
   Local X:Int = XNETGetInt (SessionObject,_slot_001)
   Local Y:Int = XNETGetInt (SessionObject,_slot_002)

   DrawOval X-5,y-5,10,10
            
               
   EndIf
   
Next

EndFunction


Function DrawSessionInfos ()

     Local Y:Int

   SetColor 255,255,255

   'Render a List with connected Sessions (NOT OBJECTS !!!)

   For Local cSession:TxnetSession = EachIn Local_Session._sessions

   DrawText "ID:"+cSession._sessionID               ,  3,y*10
   DrawText "IP:"+TNetwork.StringIP(cSession._IP)      ,100,y*10
   DrawText "port:"+cSession._Port               ,300,y*10
   DrawText "LRCV:"+(MilliSecs()-cSession._lastreceive)   ,400,y*10
         
   y:+1
                     
   Next

End Function


Function SendSessionUpdates ()

   local_object1.SetInt    (_slot_001 ,MouseX())                 
   local_object1.Setint    (_slot_002 ,MouseY())                 


   'IF mousedown create a MessageObject by our Local_Object1 and set Int by MouseBtn
   
   Local mouseBtn:Byte
   
   If MouseDown(1) mouseBtn = 1
   If MouseDown(2) mouseBtn = 2

   If mouseBtn

      Local MSGObject:TXnetSessionObject = XNETCreateMessage (Local_object1)

      XNETSetInt (MSGObject,_slot_001,mouseBtn)
      
       XNETSendMessage (MSGObject)
   
   EndIf

EndFunction


So now its time for the serverpart, to register Hosts and get lists with Hosts, and than i do make it possible to buy a license.


mfg. C64


(wenn übersetzung gewünscht wird bitte sagen !)
Betreten verboten! Kinder haften für ihre Eltern!
  • Zuletzt bearbeitet von c64 am Mo, Feb 23, 2009 21:57, insgesamt einmal bearbeitet

Firstdeathmaker

BeitragSo, Feb 22, 2009 13:54
Antworten mit Zitat
Benutzer-Profile anzeigen
Zwei Fragen:

Soweit ich sehe, kann man also nur int übertragen? Was ist mit Floats etc.?
Du benutzt ja UDP... wird das auch abgesichert? Also machst du nen crc-check oder irgendetwas um sicherzustellen dass die Nachrichten auch ankommen?
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image
 

c64

BeitragSo, Feb 22, 2009 14:05
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,

Nein man kann von Byte bis String alles übertragen, ups nagut Short hab ich vergessen Smile .

Nein momentan gibt es keinen Check, das kommt aber noch ins todo ! Dennoch functioniert es auf einem Rechner mit XX Instancen absolut Fehlerfrei, na gut die Pakete haben ja keinen langen weg, aber ich schätze (hoffe) mal es wird im Netz genauso gut funktionieren, aber wie gesagt kommt aufs todo mit dem Check.

Wenn du es in Action sehen möchtest kannst du ja mal in meinen Holocube Worklog schauen, dort ist es bereits integriert leider konnte ich es bis jetzt noch nicht übers Internet testen, da wird es einwenig mehr ausgelastet als bei dem Sample.

Danke fürs Interesse, mfg. C64 .


PS: Der HostManager ist so gut wie fertg und wird mit dem nächsten Update kommen.

@liver2009 The Hostmanager is good as ready and it will come with the next Update.
Betreten verboten! Kinder haften für ihre Eltern!

Firstdeathmaker

BeitragSo, Feb 22, 2009 14:30
Antworten mit Zitat
Benutzer-Profile anzeigen
Und noch was: Kannst du die Manual nicht über bbdoc realisieren? Dann brauchst du nicht extra noch nen .doc dazuzulegen und kannst es direkt beim coden schreiben. Hilf mir jedenfalls immer ziemlich wenn ich nen modul schreibe...

Und wie hast du die verknüpfung
Beispiel Zeile 81:
Code: [AUSKLAPPEN]
Local Sender:tXnetSessionObject = XnetMessageObject (Message)

gelöst? Über nen TMap?

Legst du am ende den Sourcecode offen? Weil man sich darüber die meisten Fragen glaube ich selber beantworten könnte Wink
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image
 

c64

BeitragSo, Feb 22, 2009 15:35
Antworten mit Zitat
Benutzer-Profile anzeigen
Also ich mag meinen Code irgentwie nich mit kommentaren auskleiden, aber in diesem fall werde ich zumindest mal die Haupfunktionen mit BBdoc dokumentieren lassen.

Nein sind keine TMAPS wäre glaub ich zu langsam Smile bei vielen Messages und Objecten. Ich habe das anders gelöst- Messages sind SessionObjecte werden aber beim versand als Message gekennzeichnet und dann Lokal anstatt in die Objectliste in eine MessageListe gepackt, also rel. einfach gelöst Wink.


Nein Sorry den Source werde ich so schnell nicht veröffentlichen.



mfg. C64
Betreten verboten! Kinder haften für ihre Eltern!
 

liver2009

BeitragMo, Feb 23, 2009 3:53
Antworten mit Zitat
Benutzer-Profile anzeigen
thanks for the reply.
like Firstdeathmaker said,also it's a problem to make sure most
of the packets have arrived! if i remember correct, in Gnet it uses Enet which support Reliable UDP messages,to make sure the packets arrived.

i had tested this on a remote server,worked fine.most of the
values can be sent and received,the circle on my screen can move smoothly(at least in my test)! that's why i want to use this mod.

look forward to getting the next version soon,
if you want to make this for sale,please add a buy link on share-it,
that's the only platform i can use in asia.also i hope the paid users
can get the source files,that will be the best help!!!
 

c64

BeitragMo, Feb 23, 2009 17:10
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi liver2009,

I'm ready with the Script struff wich will be add Hosts and get Hosts form a Webserver, today i've got register a Account on Schare'It wait some days and you can Buy a License for XNET but note ! All stuff is included and Works fine but somethings needs a Update or a Modify, and the Webstuff need's Securechecks its ALL in WORK!!! and come with the next Updates.

It was hard work to build this Library and i think it's realy Ok when i sell it for Poeples they want sell her own Products. Freeware can use it all times without limitations and without to buy a Xnet License.

The Sources don't be Included, but if you have a License i can do Send you this Wink (as a gift (thx) for your great Feedback !)

------------------------------------------------------------------------------

Hi Community,

So so, also es hat sich ein wenig was getan, ich habe den Scriptpart nun auch integriert und es ist nun möglich mit ein paar einfachen Befehlen einen Host auf einem Webserver anzumelden und eine Hostliste von diesem zu bekommen. Da ich parralel auch an Holocube arbeitet gaht alles zwar stetig aber doch nur in kleinen Schritten vorran.

FDM's ("Frage") Ratschlag werde ich mit dem Nächstem Update realisiert haben, allerdings habe ich mich dazu entschieden nur bei den MessageObjecten einen Secutity Check einzubauen, da es sonst zu einer Rapiden Performance einbusse kommen würde.

Zudem habe ich FDM's vorschlag beherzigt und mit BBDOC zumindest die Hauptfunktionen spartanisch dokumenttiert.

In Battle-Blocks hatte ich ein ählnliches System allerdings war der Battle-Blocks Netzwerkcode nur für 2 Clienten gedacht und somit wars einfach das zu Implentieren. Aber es kahm dort zu immensen Stockern wenn nachrichten neu Gesendet wurden, allerdings war es für ein Tetris unerlässlich das die Daten in der Richtigen reienfolge und Komplett ankommen Smile.

Was ich damit sagen will ist das es sicher Realisierbar ist per UDP eine 100% garantie zu bekommen für Nachrichten, aber dies für Actionreiche Ballerspiele doch eher genau überlegt sein sollte, deswegen wird der eigentliche Objecttraffic normal weiterlaufen aber es wird die Möglichkeit geben Messages zu verschicken bei denen ein Ankommen 100% Garantiert ist !!

Ich hoffe das diese Lösung in Ordnung ist da es auch möglich wäre Daten nur mit Messages auszutauschen.


mfg. C64
Betreten verboten! Kinder haften für ihre Eltern!

Firstdeathmaker

BeitragMo, Feb 23, 2009 21:02
Antworten mit Zitat
Benutzer-Profile anzeigen
Eine anmerkung: Wie wäre es, wenn du dem Benutzer einfach die option gibts, Messages als wichtig zu markieren (welche dann unbedingt ankommen müssen) oder eben als nicht relevant zu markieren, welche dann nicht überprüft werden bzw. bei Fehlern einfach verworfen werden?

Und noch was zum Thema TMaps und langsam:

https://www.blitzforum.de/foru...723#322723

Es lohnt sich schon ab 100 Objekten.
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image
 

c64

BeitragMo, Feb 23, 2009 21:43
Antworten mit Zitat
Benutzer-Profile anzeigen
Ja genau so werde ich es auch machen ich erweitere einfach nur meine MessageRoutine. So dass man beim senden ein Flag setzen kann.

Ja mit den TMaps glaub ich dir gut und gerne aber ich habe ja alles in Listen und da brauch ich nix raussuchen da Sessions jeweils Listen und Arrays zur verwaltung von Objecten nutzen. Da jede Session und jedes Object eine Eindeutige ID nummer hat und weiss zu welcher Session es gehört kann ich ohne weiteres mit dieser ID auf die Session zugreifen von der es kommt und aus dieser mit hilfe des ObjectArrays das Object bekommen das zu dieser ID gehört.


Code: [AUSKLAPPEN]

Function XNETMessageObject:TXnetSessionObject (MSGObject:TXnetSessionObject)
      Return MsgObject._session._objectByID[MSGObject._ID]
EndFunction


Ansonsten nix gegen TMAPS so war das nicht gemeint ich hatte ja auch nur vermutet !!

Wollte nur sagen das ich schon eine andere Lösung habe und auch nie vor dem Problem stand. Ich habe auch schon TMaps benutzt nur halt nich hier.


Dennoch Danke für deine Fürsorge !!! Smile

mfg. C64 !!
Betreten verboten! Kinder haften für ihre Eltern!

Firstdeathmaker

BeitragMo, Feb 23, 2009 21:50
Antworten mit Zitat
Benutzer-Profile anzeigen
Ah okay, direkte arrays sind natürlich noch was ganz anderes, das wusste ich nicht Wink
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image
 

liver2009

BeitragDi, Feb 24, 2009 3:02
Antworten mit Zitat
Benutzer-Profile anzeigen
sounds great!
now i am waitting for the good news.money is ready now Razz
thanks for your kind to offer the source,that's important for me
to modify some functions for my new project!!!

happy coding!!
 

c64

BeitragMi, Feb 25, 2009 16:23
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi liver2009,

Look Here !
Betreten verboten! Kinder haften für ihre Eltern!
 

liver2009

BeitragDo, Feb 26, 2009 3:25
Antworten mit Zitat
Benutzer-Profile anzeigen
hi C64,
nice web site,
while i am waitting for your new "complete" version, i am now
trying to integrate Xnet to my project. i will definitely buy a license
once you release the next version.

also i wonder more details about G2D?
 

liver2009

BeitragSo, März 01, 2009 7:42
Antworten mit Zitat
Benutzer-Profile anzeigen
hi,c64,
how is everything?
 

c64

BeitragSo, März 01, 2009 12:47
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi liver2009,

It's ready for the first time, all stuff is included now and works fine. Bevore I include SecureMessages i make a Test over the Internet (thx to The_Schadow3) with over 50 SessionObjects no Packet was lost and no Bytes was killed (error bytes) this means all was right bevore but now it doe's supports SecuretyMessages too.

Security Messages will be checked for Receives, it doesn't come a Receive to the Sender the Message will be Resend 5 times, each send will be checked for a Receive, if the Client Receive the Message and the MessageReceive Message come to late to the Sender, the Sender resend and the Client will ignore this messageData but send a Receive.

Let's look was the Future brings for XNET but now, for the first time, it's ready.


More infos about G2DE (GE2D) not avaible, this Engines are a litle thing older, over the time i change my codestyle and write now @Xengine2D it's the same as G2DE and GE2D (Game2dEngine and GameEngine2D) with better code.atm. I don't work on Xengine2D atm. . I work on Holocube nE. for this I need XNET (it's ready) and a newer GUI when this its done i look again to my 2D Stuff.


sincere regards C64.
Betreten verboten! Kinder haften für ihre Eltern!

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group