C
C#12mo 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
Buddy12mo 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
TimOP12mo ago
Hmm I guess- then I would have to block until that message has arrived tho
Buddy
Buddy12mo ago
You can, sure. But you don't need to.
Tim
TimOP12mo ago
Can I just use a task for that?
Buddy
Buddy12mo ago
You can just use the asynchronous API in Socket if you don't want to block
Tim
TimOP12mo ago
I'm not using socket
Buddy
Buddy12mo ago
Oh?
Tim
TimOP12mo ago
But ig I could create some task that waits I'm doing cross process communication with pipestreams
Buddy
Buddy12mo ago
Oh, I see.
Tim
TimOP12mo 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
Buddy12mo ago
blobthumbsup
Want results from more Discord servers?
Add your server