Gnet Bug, Please i need a running Fix !!
BlitzMax Forums/BlitzMax Programming/Gnet Bug, Please i need a running Fix !!
| ||
Hi, (sry bad english !) Please i need HELP or a fix !! to get the right GnetMessageObject from a GnetMessage. I wrote a litle Samplecode, i need GnetMessages and i got no time to write a new "lowlevel- NetLib" like Gnet for me, and Gnet allready exist and it works fine but this one problem is a Great Problem and it makes Gnet bad. I try the Fix http://blitzbasic.com/Community/posts.php?topic=80476 but it doesn't work Try This code and start more Instances, every GnetObject send a Message (all 2000 Millisecs), in a normal case each Client must receive a remote message and do print a ID string but nothing like this "Sender Is LocalClient" is happens. '////////////////////////////////////// '/ '/ '/ '/ GNET BUG !! '/ '/ ----------------------------------- SuperStrict Import brl.gnet Global _self :TgnetHost = CreateGNetHost () Global _localclient :TgnetObject Global Port :Int =12345 Global Counter :Int If Not Join () Host () GNetListen (_self,Port) Graphics 100,40,,0 Repeat Cls If KeyHit(key_escape) Or AppTerminate () End ControlMessages () ControlObjects () If MilliSecs()-Counter > 2000 Counter=MilliSecs() SendMSG() Flip Delay (50) GNetSync (_Self) Forever Function Join:Byte() If GNetConnect (_Self,"127.0.0.1",Port,1000) _localclient = CreateGNetObject (_Self) Print "Client" AppTitle="Client" Return True EndIf End Function Function Host:Byte() _localclient = CreateGNetObject (_Self) If _localclient Print "HOST" AppTitle="HOST" Return True EndIf EndFunction Function ControlMessages() Local Message:TGnetObject If _Localclient For Message=EachIn GNetMessages(_Self) Print"______________" Print"INCOMING MSG :" Local MSGObj:TGNETOBJECT = GNetMessageObject (Message) If GNetObjectLocal (MSGObj) Print "SENDER IS LOCALCLIENT ?!!?!!" If MSGObj Local TargetObject:String = String(GetGNetTarget (MSGOBJ)) If TargetObject Print "from : "+TargetObject EndIf Next EndIf EndFunction Function ControlObjects() Local NetObject:TGnetObject If _Localclient For NetObject=EachIn GNetObjects(_self) If GNetObjectLocal (NetObject) Continue Local State:Int=NetObject.State() Select State Case Gnet_Closed Print"________________" Print"Client CLOSED :" Local TargetString:String = String(GetGNetTarget (NetObject)) If TargetString Print "ID : > "+TargetString+" <" Continue Case Gnet_Created Print"________________" Print"Client Created :" SetGNetTarget (NetObject ,String("REMOTECLIENT :"+String(MilliSecs())) ) Local TargetString:String = String(GetGNetTarget (NetObject)) If TargetString Print "ID : > "+TargetString+" <" EndSelect Next EndIf EndFunction Function SendMSG() Local MSG :TGNETOBject = CreateGNetMessage (_self) Local RCVClient:TGNETOBject '= _localclient For RCVClient = EachIn GNetObjects(_Self) If GNetObjectLocal (RCVClient) Print "MSG RCVR is LocalClient MSG not send !!" Continue SendGNetMessage (Msg,RCVCLient) Print "SEND" Next EndFunction thanks for any help !! |
| ||
Hi, GNetMessageObject returns the object the message was sent *TO*, which will always be a local object as far as the receiver is concerned. There is no *from* mechanism to identify the sending object - you can implement this is you want using SetGNetXYZ on the message before sending it. I suspect you are not using GNet the way it was designed - the message objects are meant to contain simple message like 'begin game', 'abort game' etc commands sent from the game server to all game objects. For a more pure messaging API, try eNet. |
| ||
Ok thx for your Awnser. I do use Messages for Shoot's, i think messages have a greater chance to be received 100% from clients. I handle Logins and Logouts with another solution. Each GnetObject become a Target if not Target exist the Object must be a new (a Login) Object and then it will be bind as a GameClient, Position etc. are transmitted with GnetSETXYZ and it works fine but when i use it for realy importent Messages like Shoots it doesn't work 100% also i think Messages are a the better way to send shoots btw. to send realy importent Messages. But GnetMessages don't send a Referenz from where it come and in this case a Gnet User must write a SessionID system, then a Message do send a simple ID wich will be Identifikated a Client who have send a Message. And now the a big WHY ! Why Messages don't send the GnetHost or the GnetObject from where it come. it can makes many things easier. In fact, a MessageObject is a standard GnetObject so i think IT MUST SEND a *from* ! :) !! It doesn't exist a good Manuell for GNET only some Codes i can find to learn Gnet. In the process where i learn'd Gnet, i find it very good but this one stupid thing makes that i now write my on NetLib (i think time is Importent but running Code does have more Priority.) it's not a problem but the time :( , ok it's not hard work to Implement a ID system but it exist one and it identifikats Objects but not Messages this is not a good way and another problem is the UserManuell that doesn't exist for GNET then to know how work with Gnet you must know how work Gnet ! ( i hope you can understand what i have write ) (if you want take a look how does it works atm. try this http://www.c64.feuerware.com/new_hc/downloads/HC_nettest.rar , change the Resolution to 500x500x32x2 (first 4 lines in settings)and start 2 Instances (ip and resolution can set in Settings.set , it runs very fine but now i must rewrite the NetLib ) bye C64. |
| ||
I also have to say I think this would be a great feature. Why not give the ability to do such a thing in every way possible? |