Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Initial State:
- Client: client_token = false
- Server: server_token = false, new_messages = false
- Step 1: Client sends request
- Client sends client_token = false
- Message successfully received by server
- Step 2: Server processes request
- Server sees client_token == server_token
- Sets new_messages = false
- Responds with server_token = false
- Response successfully received by client
- Step 3: Server generates new message
- Server sets server_token = true (flipped)
- Sets new_messages = true
- Step 4: Client sends another request
- Client sends client_token = false
- Message successfully received by server
- Step 5: Server processes request
- Server sees client_token != server_token
- Keeps new_messages = true
- Responds with server_token = true
- This response is lost due to unreliable channel
- Step 6: Client doesn't receive response
- Client's state remains unchanged
- client_token still false
- Client is unaware of new messages
- Step 7: Client sends another request
- Client sends client_token = false again
- Message successfully received by server
- Step 8: Server processes request
- Server sees client_token != server_token
- Sets new_messages = false (This is the error!)
- Responds with server_token = true
- Response successfully received by client
- Step 9: Client processes response
- Client sees server_token != client_token
- Client pulls messages and updates client_token = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement