writeMessage

Returns a handshake message only if this is appropriate given the pattern and state.