web3-starter-py/small-projects/maze-puzzle
2022-03-23 18:41:46 +04:00
..
src Add dir with some small projects 2022-03-23 18:41:46 +04:00
tests Add dir with some small projects 2022-03-23 18:41:46 +04:00
.gitkeep Add dir with some small projects 2022-03-23 18:41:46 +04:00
README.md Add dir with some small projects 2022-03-23 18:41:46 +04:00

Follower Maze Code Challenge Instructions

Follower-Maze is a client-server application built for social networking. Users follow other users, post messages, send private messages, unfollow users, and so on.

  • Each of these actions is an event, created by an event-source and sent to the server.
  • Each event is processed by the server.
  • The processing of the event may have follow-on effects on other user-clients.

The server listens for two kinds of clients:

  • 1 event source, which emits events.
  • N user-clients that connect to the server.

Client/Server Protocol

  • The protocol is line-based i.e. a LF control character terminates each message. All strings are encoded in UTF-8.
  • Data is transmitted over TCP sockets.
  • The event source connects on port 9090 and will start sending events as soon as the connection is accepted.
  • The user clients connect on port 9099 and identify themselves with their user ID. For example, once connected a user client may send down 2932\r\n, indicating that it is representing user 2932.
  • After the identification is sent, the user client starts waiting for events to be sent to them by the server.

Events

There are five possible events. The table below describes payloads sent by the event source and what each represents:

| Payload       | Sequence # | Type          | From User Id | To User Id |
|---------------|------------|---------------|--------------|------------|
| 666|F|60|50   | 666        | Follow        | 60           | 50         |
| 1|U|12|9      | 1          | Unfollow      | 12           | 9          |
| 542532|B      | 542532     | Broadcast     | -            | -          |
| 43|P|32|56    | 43         | Private Msg   | 32           | 56         |
| 634|S|32      | 634        | Status Update | 32           | -          |

Event Rules

  • Each message begins with a sequence number.
  • However, the event source does not send events in any given order. In particular, sequence number has no effect on the order in which events are sent.
  • Events may generate notifications for user clients. If there is a respective target user client connected, the notification is routed according to the following rules:
    • Follow: Only the To User Id is notified
      • A follow event from user A to user B means that user A now follows user B.
    • Unfollow: No clients are notified
      • An unfollow event from user A to user B means that user A stopped following user B.
    • Broadcast: All connected user clients are notified
    • Private Message: Only the To User Id is notified
    • Status Update: All current followers of the From User ID are notified
  • If there are no user clients connected for a user, any notifications for them are currently ignored. User clients are notified of events in the correct sequence-number order, regardless of the order in which the event source sent them.