mercredi 26 mai 2021

How to handle conditions when using the TypeState pattern?

I am currently learning the TypeState pattern and came into a situation that is not covered by online examples.

Let's suppose that I have a Connection object with a state. The new() method for the object performs an authentication handshake with a remote server, and it's for this handshake that I want to use the TypeState pattern. My problem is how to handle conditions.

When performing the authentication handshake I need to send a Hello packet to which the server then responds with a list of authentication methods (no password, plain text password, md5 password).

From my understanding, the TypeState pattern always knows which state to return next. What happens when I have 3 options?

Aucun commentaire:

Enregistrer un commentaire