UdpClub banner

UdpClub

9 devlogs
11h 57m 28s

A library for C# designed to help speed up the development of UDP networking apps.

Loading README...

averytoad65

We got a logo now! Whipped up this cool little network of circles, because I thought it’d fit the project really nicely. Also I fixed a bug where every RPC in the project would get called if you called a single one. i.e. if you had the RPCs “UserJoinMessage”, “UserLeaveMessage” and “UserEmojiReact” and you called the RPC for “UserJoinMessage” it would actually trigger all 3 RPCs. That is now fixed, silly me. Also I have swapped a few more debug-prints for the DebugPrintln function. Yay! Happy coding and thanks for reading!

Attachment
Attachment
0
averytoad65

RPCs work! I repeat, they fully work! I have freaking done it! I am so happy with myself for managing to fix RPCs so quickly - only took me 24 minutes, huh. I have also made some changes to some not-so-relevant parts of the source code, like replacing lots of the aforementioned statements that I wrapped in “#if DEBUG” to use my DebugPrint/DebugPrintln functions. But, back to the main course, I managed to figure out a nasty bug in parsing RPCs that would cause the network thread to hang indefinitely because of an unhandled exceptions (thanks, Rider Debugger for pointing that out to me..)
And.. yeah! I guess it’s time to clean up some code, write the demo project and maybe look into more parameters? Who knows! What I know for sure is that I’m gonna blast Good Kid music now. Cheers!

Attachment
Attachment
0
averytoad65

Another day, another… four hours of work? Damn. I didn’t even realize. Alright, well, here’s what I spent my time doing today, and what I will continue to do because I want this project to freaking work.
So! I worked on a little demo project, because I planned on shipping an initial release of UdpClub soon. But there’s a slight issue with that, the app I want to make for my demo is a basic messaging app between multiple clients, only issue is that I want to include things like a welcome message when a user joins and some other stuff where an RPC with a parameter would be lovely. Only issue is… I can’t do that. For something as simple as a welcome message I just simply want to be able to call an RPC and have it invoke everywhere. Annoyingly, I was too lazy to implement that when my mind understood the awful code I wrote! Now I have to dive back in and debug it. And that’s what I’ve been doing! Well, ok, I did also work on the basic demo project, but who cares about that. Anyhow, during these four hours of debugging my code I have noticed how incredibly fragile the system is and how badly I want to remake it to be way clearer to debug and use, so, uh… RPC rewrite today? Maybe? Who knows. Though, today I will probably only get RPCs with one parameter working and like.. replace all my manual #if DEBUG /* print */ #endif statements with an abstraction, which I called “DebugPrint”. Anyways, that’s basically all. Let’s hope that I can get this resolved ASAP when I’m home and not bothered by school, the new NullReferenceException is definitely promising… Cheers!

Attachment
0
averytoad65

Not a lot of changes for right now, but that’s mainly, because I spent my time making an EXE for SWP so the ship doesn’t get rejected again.
But, I implemented a small feature.. loopbacks! A loopback lets you specify if the RPC Package should return to the sender once the client sends it to the server, this is useful so there is less confusion about if you should run the RPC function locally as well, or if the package comes from the server-side. It also has practical usages, but I can’t think of any examples off the top of my head.
Next up is (hopefully) documentation and cleanup of the existing RPC handling code. Let’s see how that goes.
Happy coding and thank you for reading!

Attachment
0
averytoad65

… so I spent 3 hours implementing RPCs (Remote Procedure Calls), and boy oh boy… it’s a mess, like most things in this!
So, let’s dive into it, shall we?
At first I began with writing a RPC Attribute class, plain and simple, afterwards a small RPCManager to ensure that I can easily call RPCs from anywhere. Then followed a small RPC Package to make it easy for the server to communicate that the clients should execute a function, all well and good… Until it came to implementing how you’re supposed to run the function. Granted, I took the easy way out: only allow static methods. But I don’t want that to be the case forever, I want this to eventually run on object instances too, but that’s gonna take a bit for me to do. Probably past the time limit of this whole Flavortown thing, so, screw it. Anyways, so after implementing all that, I was met with an issue: RPCs weren’t registering. So, what did I mess up? Well I had the call to subscribe my RPC to the RPCManager in the RPCAttribute constructor, should work, right? Well, the developers of roslyn (the C# compiler) decided to throw me a giant “F**k you,” because the constructor for an Attribute is never called until you somehow reference the RPC via MethodInfo.GetCustomAttributes() and whatnot… suffice to say it took me a bit to figure out.
But, hey, I finally did it. Now you can register static functions are RPCs with a specific ID and you can easily call ‘em through the server, now all I have left to do is make the communication system with the RPCPacket work in a way that a client can request to execute a RPC to the server and then the server can spread that message to other clients.. and I should definitely get parameters working. But, I think first I’ll focus on cleaning up this steaming mess of redundant calls and whatnot, and heavy documentation, right now only god and I know what this code does, not very sustainable.

Anyhow, happy coding!

Attachment
1

Comments

sl4shed
sl4shed 11 days ago

seems interesting. keep up the work!

averytoad65

gotta make this quick, sorry..

  • Added IPEndPoint to BasePackage
  • Added two new test packets to Test projects
  • Fucked up with the gitignore for packages and whatnot (gonna fix that immediately tmr)
  • Updated PackageHandler to include new functions for sending packets
  • update predicate for finding correct BasePackage constructor w/ correct new parameters and debugging stuff
  • more prolly

thanks for reading!

Attachment
Attachment
Attachment
1

Comments

averytoad65
averytoad65 23 days ago

ok so turns out that you can just clone the project and it will download NUnit automatically even without the packages dir, good to know! although I should probably also test this on my laptop to be 100% sure…

averytoad65

I feel like one of the best programmers of all time right now - my complex workaround for making a dynamic package library somehow worked on the first try! I managed to finally make it so you can easily initialize a UdpClientApp or UdpServerApp and send packages from it! And it just… works! As long as you make a registry for the packages which adds them to PackageHandler.Packages using PackageHandler.RegisterPacket(…) but that’s beside the point. What I mean to say is that, the fundemental principle of my application is done, a more simplistic way to send and parse data packets over a network. Can it be optimized? 100%. Will I optimize it? Perhaps, we’ll see how much time I have for that until I ship the project. For now though, I will happily enjoy this win and dance around like a silly goober to “Na Na Na (Na Na Na Na Na Na Na Na Na)” by My Chemical Romance. See ya, and thank you, you lovely individual, for reading this!

Oh, also, if you care to check out what I made and you can’t find the GitHub repo, you can find the project source code at: https://github.com/averyocean65/UdpClub/

Attachment
Attachment
0
averytoad65

… so turns out the fix for the communication issue between the Client and Server was simply because the client was using the IP EndPoint used in “UdpClient.Receive(…)” to communicate messages, which apparently doesn’t work for sending stuff to the server - the more you know! Thanks C#.

Anyhow, the issue is fixed now using a simple if-else statement lol. Took me about 3 minutes to figure out.

I also worked on a package class as well as a PackageMap, I also took baby steps in creating the PackageHandler. Now, unfortunately, I am not sure how to build a modular system for building and identifying packets, so I’ll have to get back to my mental drawing board until something comes to mind.

Attachment
0
averytoad65

I finally got a basic framework running to send data between a server and client via the UDP protocol. I am extremely happy to see that I got it up and running from only an hour of work. Unfortunately there is a bug in the package handling, as the server and client should constantly send packages to each other, so I have to do some debugging to see what’s going wrong. Very strong start though! Hope I can get the Package and Package Manager classes implemented tomorrow if I manage to iron this bug out.

Attachment
0