Advertisement
Guest User

Untitled

a guest
Oct 17th, 2024
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Initial State:
  2.  
  3. Client: client_token = false
  4. Server: server_token = false, new_messages = false
  5.  
  6. Step 1: Client sends request
  7.  
  8. Client sends client_token = false
  9. Message successfully received by server
  10.  
  11. Step 2: Server processes request
  12.  
  13. Server sees client_token == server_token
  14. Sets new_messages = false
  15. Responds with server_token = false
  16. Response successfully received by client
  17.  
  18. Step 3: Server generates new message
  19.  
  20. Server sets server_token = true (flipped)
  21. Sets new_messages = true
  22.  
  23. Step 4: Client sends another request
  24.  
  25. Client sends client_token = false
  26. Message successfully received by server
  27.  
  28. Step 5: Server processes request
  29.  
  30. Server sees client_token != server_token
  31. Keeps new_messages = true
  32. Responds with server_token = true
  33. This response is lost due to unreliable channel
  34.  
  35. Step 6: Client doesn't receive response
  36.  
  37. Client's state remains unchanged
  38. client_token still false
  39. Client is unaware of new messages
  40.  
  41. Step 7: Client sends another request
  42.  
  43. Client sends client_token = false again
  44. Message successfully received by server
  45.  
  46. Step 8: Server processes request
  47.  
  48. Server sees client_token != server_token
  49. Sets new_messages = false (This is the error!)
  50. Responds with server_token = true
  51. Response successfully received by client
  52.  
  53. Step 9: Client processes response
  54.  
  55. Client sees server_token != client_token
  56. Client pulls messages and updates client_token = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement