I am new to actors and trying to implement a very sequential protocol handshake (over websockets). This is in Scala/Akka.
It goes something like this:
- HTTPs connection is established then upgraded to websocket
- Client says HELLO
- Server responds HELLO
- Client says I want to use subprotocol X or Y
- Server says I support Y and will start using it
- Client starts talking using subprotocol Y
My question is one of proper practice on the server side. Should I have a single actor for the connection, that is updated with the state of the handshake (for example, with a sequence like CONNECTED->RECEIVED_HELLO->RECEIVED_OFFER->BEGIN_SUBPROTOCOL->..(do work)..->CLOSE_CONNECTION) using messages-to-self & ask?
Or is there a better pattern for such a serial/synchronous protocol initialization?