NetWrapper - a simple and lightweight networking library
34 replies, posted
[QUOTE=Abdul;44881993]Do I need to use AddNetworkString for GetNetVar/SetNetVar to work?[/QUOTE]No.
Switched entire RP/Basewars-ish gamemode over to this and it seems to help performance. There were so many DT and NW vars being used for each entity I just had to see what would happen.
One good thing is that players no longer get stuck in place when they first join.
Would that be because the net messages now arrive neatly in a single table instead of in tons of individual messages?
I'm interested in seeing some benchmarks.
Great work OP.
[QUOTE=Mitsudigi;44987998]Switched entire RP/Basewars-ish gamemode over to this and it seems to help performance. There were so many DT and NW vars being used for each entity I just had to see what would happen.
One good thing is that players no longer get stuck in place when they first join.
Would that be because the net messages now arrive neatly in a single table instead of in tons of individual messages?
I'm interested in seeing some benchmarks.
Great work OP.[/QUOTE]
Thanks for the feedback. I'm glad to know this is still being used!
I also converted my sandbox server from -> using DT Vars on players (which was horrible since you can't name the index to use) and NW Vars on entities to -> this library and I'm absolutely love how simple it is.
It feels kind of weird saying that, but writing this library has honestly made my projects so much simpler and neater than trying to mix DT and NW vars.
As far as efficiency and benchmarking go, I'm not particularly comfortable in attempting anything without having a better understanding of what the Set/GetNW functions and the net library are doing internally.
I haven't seen any signs of performance degradation, which is more than I could really ask for. But I guess it really comes down to whether the DT/NW functions are constantly networking the variables or only when the values change (like in this library), or if NW is really just a wrapper around the net library or something like that.
But again, thanks!
[editline]3rd June 2014[/editline]
[B]On a side note, I just updated both GitHub branches with an update that addresses an issue when trying to network 'false' on an entity.
The way the return statement was set up in ENTITY:GetNetVar was making it return nil (or worse, the default value) when the value was false, even though it should've just returned 'false'. This has been fixed!
[url]https://github.com/Mista-Tea/netwrapper/commit/5f6bcd3989ee0e950c605daa891a6e2ba3537ecc[/url]
[/B]
It's been a while since my last update on this thread.
I've added a new feature to the NetWrapper library called [B]Net Requests[/B]. I suppose this is similar to how DarkRP networks the owners on door entities. Basically you can now determine exactly when you want values to be networked to a client, instead of automatically being broadcasted to connected clients or synced to connecting clients. The whole reason I added this feature was because I run a sandbox server were there may be over a 1,000 props spawned out at any given time. I used ent:SetNetVar() to networked the name of the props so that players could see who owns the client when they look at it inside HUDPaint. By using ent:SetNetVar() on those 1,000s of props, any connecting clients would receive 1,000s of small net messages from the server that ask for any networked data. The messages are small enough that it isn't too big of an issue, but if I were networking multiple values on every prop it would quickly escalate. So, instead of getting 1,000 net messages when you connect, you get 0. The only time the values are networked are when you explicitly call [B]ent:SendNetRequest( key )[/B] to retrieve a value stored on this entity at the given key from the server.
The new functions you directly call are :
[CODE]ent:SetNetRequest( key, value ) -- shared
ent:GetNetRequest( key ) -- shared
ent:SendNetRequest( key ) -- client[/CODE]
All of the other Net Request functions are used internally.
Anyway, I'm not very good at explaining these things, so take a look at the new README.md file on GitHub instead: [URL]https://github.com/Mista-Tea/netwrapper/blob/master/README.md[/URL]
I've also come up with a better example that shows both Net Vars and Net Requests: [URL]https://github.com/Mista-Tea/netwrapper/blob/master/lua/netwrapper/example.lua[/URL]
And as always, the code is available on [B]GitHub[/B]:
[B]Addon version[/B]: [URL]https://github.com/Mista-Tea/netwrapper/tree/master[/URL]
[B]Single, shared file version [/B](drop it into your own addon): [URL]https://github.com/Mista-Tea/netwrapper/tree/condensed[/URL]
The addon version has actual documentation for the new Net Request functions, so if there is any confusion, read them. Other than that, it's pretty simple.
This is amazing. I was just thinking that I needed something like this and wasn't sure how it should be done. Didn't even realize someone made something like this, great work and keep it up.
Sorry, you need to Log In to post a reply to this thread.