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
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.
Hmm
I guess- then I would have to block until that message has arrived tho
You can, sure. But you don't need to.
Can I just use a task for that?
You can just use the asynchronous API in Socket if you don't want to block
I'm not using socket
Oh?
But ig I could create some task that waits
I'm doing cross process communication with pipestreams
Oh, I see.
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