Not the best week, I didn't get much done Monday to Wednesday.

Monday

I took the day off to go hiking. I wanted to do about 20 KM, so I did Stage 4 and Stage 5 of the Maclehose Trail. The last time I walked these two trails was in November 2011, a few days after I moved back to Hong Kong. It was a lot easier this time.

Tuesday

- [x] Reply to Shlok
- [x] Pay Nadia
- [x] Pay Netvigator Bill
- [x] Keep track of users that have sockets open?
- [x] Remove a socket when the user leaves
- [x] Max number of websockets you can keep open?

I think I worked from home last Tuesday, and it looks like I didn't get much done. A bunch small admin tasks and some testing of web sockets.

Wednesday

- [x] Reply to Polly
- [x] Android: Billing API Upgrade https://developer.android.com/google/play/billing/integrate
- [x] Handle CREATE_STARTED_STORY socket messages
- [x] PROD is down

Prod went down because of a database migration that failed, so I fixed the migration and it came back up. I got an email from Google Play saying I must use the new Billing library by November 2021. Girlfriend Plus is currently using an unsupported Billing library, so I'll have to remove all that code and dump in the new library. That'll be fun.

Thursday

- [x] Create a GetPendingInteractions Action
- [x] Delayed messages should be sent down the socket when they happen
- [x] InteractionTraverser.getPreviousMessages() should have a sequenceId on it.
- [x] UIDeltaChatMessage should have a sequenceId and storyId on it
- [x] SocketMessageHelper methods to clean up test code.
- [x] Send PendingInteractions after a CREATE_STARTED_STORY message
- [x] handleMessage should parse the message once
- [x] ClientMessages should be parsed the way Interactions are parsed. Using the `type`
- [x] ServerMessages should be parsed...
- [x] Send ChatDecision down the websocket when the last PendingInteraction has arrived
- [x] CreateUserChoiceAction, WS and HTTP code.
- [x] Handle CREATE_USER_CHOICE socket messages

Alright here we go! Some work is getting done. I did a lot of work on the websocket APIs. I spent a lot of time trying to model the Client and Server websocket message. I wanted every message to have a code, payload and type.

After a lot of "Annotation Bingo" and trial and error I was able to model the POJOs.

Creating the websocket API isn't too tricky, but writing the client may be a challenge. The first client I'm going to write will be Girlfriend Plus Android. Currently the Android and iOS applications have all the data bundled into them. The app retrieves Character and Message History data from a SQLite database running on the device. This means latency is extremely low.

My plan is to have some characters sourced from the database on the device, and some characters sourced from the web socket API. This means the App will have one flow for LocalCharacters and another flow for RemoteCharacters. I'm expecting the flow for RemoteCharacters to be a lot simpler because most of the logic happens on the backend. We'll see.

Friday

- [x] Player messages should be sent down the websocket after a UserChoice is made
- [x] PendingInteractions should be scheduled after a UserChoice is made
- [x] Reduce leading text in console log output
- [x] Allow overriding clock in InteractionTraverser
- [x] Jackson Parsing rules for WsServerMessages
- [x] Add Girlfriend Plus to the MessagesKit README.md
- [x] Try out message queueing WS in DEV
- [x] Add sequenceNumber to messages in `GET_ROOM_SNAPSHOT`
- [x] Move logic into CreateUserAction
- [x] WS: Auto Register a user if they do not provide a token
- [x] CHAT_MESSAGE_RESPONSE should have nextTriggerTime on it
- [x] Try out socket registration in DEV

More web socket work. It was quite a successful day, the web socket can be used to:

  1. Start Stories
  2. Get all Conversations
  3. Get all messages for a Conversation
  4. Choose a response