GNet object targets
BlitzMax Forums/BlitzMax Programming/GNet object targets
| ||
What are the "targets" you can set in GNet Objects with SetGNetTarget? I'm not sure how to use them, but is it like you can keep your own users defined bmx types syncronized over the net? Any help is appreciated. |
| ||
I fear they don't get syncronized. But you can use SetGNetTarget / GetGNetTarget to hook an object to a GNetObject so you don't have to search through all objects to find its counterpart. This object is only locally a attached ... at least thats what my tests have shown (asked the same question some time ago without an answer so I figured that out on my own - might show to be wrong, but don't think so) |
| ||
Alright thanks anyway. It would be cool if you could get your own objects to syncronize but I guess that is something that will have to be done some other time. |
| ||
I'm at the moment using a little workaround trick. .ToString() and .FromString() methods to syncronize the target object through a string slot :) |
| ||
That sounds like an okay workaround, but could you show me an example of what you mean? |
| ||
You use a method that wraps all the internal data to a formated string that you parse out again with the "from" method. Something like: Type GNetAttachedObject field x:int, y:int field name:string method ToString(obj:TGNetObject,slot:int) local str:string = x + ";"+ y + ";" + name setgnetstring(obj,slot,str) end method method FromString(obj:TGnetObject, slot:int) local str:string = getgnetstring(obj,slot) x = int(left(str,instr(";"))) str = right(str, len(str)-instr(";")) y = int(left(str,instr(";"))) name = right(str,len(str)-instr(";")) end method end type *not guaranteed to work as I can't test right now* |