reactphp/socket

Interactive client example?

bilogic opened this issue · 2 comments

Hi,

I'm having trouble writing "elegant" code for an interactive client, i.e. imap client, IRC client

Specifically, I find it very hard to write in a way that makes sense which is the 1st step, which is 2nd etc due to the reactive/event driven nature, e.g.

  1. Login
  2. If login success, select a mailbox/join a channel
  3. Then check how many messages there are/who is in the chat group

Most of the samples are a 1 transaction protocols like HTTP and I can't see any that applies the concepts of await etc

Possible to make a simple example, say POP3? Thank you!

Hey @bilogic

I don't know if I understand you correctly but if your looking for a interactive communication via CLI, you should take a look at clue/reactphp-stdio. @clue also has a project that sounds similar to yours: clue/reactphp-quassel.

Hope this will help you as a first step to move on. Let me know if you have any further questions!

Hey thanks!

Doesn't have to be interactive, it's more like how to make it not take the next steps until the earlier has succeeded, e.g. don't select a mailbox until login is complete. Sometimes multiple such sequential steps are needed and it makes my code quite unreadable, let alone testable.

I'm trying to get something going with https://github.com/shuchkin/react-smtp-client, let me take a closer look at your suggestions. Thank you.