C
C#6mo ago
Tim

One time event wait

Heya! I have an event event Action<Message> MessageReceived that gets called whenever a message gets received from another program. I would like to set up some version check, so that the client needs to send a 'version check' message to the server before it will start doing anything. How can I do this cleanly using an event?
11 Replies
Buddy
Buddy6mo ago
Why do you want to use an event for that? Just immediately send it upon trying to connect to the server. Client - Connect - Send version packet Server - Receive incoming connection - Deserialize version packet - Compare if version matches. - Reply with an error packet and disconnect the user if it does not match.
Tim
Tim6mo ago
Hmm I guess- then I would have to block until that message has arrived tho
Buddy
Buddy6mo ago
You can, sure. But you don't need to.
Tim
Tim6mo ago
Can I just use a task for that?
Buddy
Buddy6mo ago
You can just use the asynchronous API in Socket if you don't want to block
Tim
Tim6mo ago
I'm not using socket
Buddy
Buddy6mo ago
Oh?
Tim
Tim6mo ago
But ig I could create some task that waits I'm doing cross process communication with pipestreams
Buddy
Buddy6mo ago
Oh, I see.
Tim
Tim6mo ago
I already have a thing that receives messages in a task, and the polls them every so often and calls an event But I think I'll just start that one after the version check And not use it for the version check Hmm yap that'l work, thanks! Epic pfp btw :O
Buddy
Buddy6mo ago
blobthumbsup
Want results from more Discord servers?
Add your server
More Posts