-
Notifications
You must be signed in to change notification settings - Fork 7
Chat
David Gerber edited this page Dec 9, 2023
·
4 revisions
Service type: 18
Is used to chat.
Contains distant chat, peer chat and distributed chat.
Item | Subtype | Purpose |
---|---|---|
ChatMessage | 1 | Contains a chat message. |
ChatAvatar | 3 | Contains a JPEG image of the peer's avatar. |
ChatStatus | 4 | Contains the chat status string (for example, Foo is typing... ). Sent at most every 5 seconds and only for private chats. |
PrivateChatMessageConfig | 5 | |
ChatRoomConnectChallenge | 9 | Contains a connect challenge code. Used to find if a peer is on the same private channel but also used for public ones. If successful, a ChatRoomInvite is sent back. |
ChatRoomUnsubscribe | 10 | |
ChatRoomListRequest | 13 | Requests a ChatRoomList item. Sent every 120 seconds. |
ChatRoomConfig | 21 | |
ChatRoomMessage | 23 | |
ChatRoomEvent | 24 | |
ChatRoomList | 25 | Contains the list of rooms a peer is subscribed to. |
ChatRoomInvite | 27 | Contains a chat room details. Sent either when responding to a challenge or when needing to subscribe to an available room. The flags are set accordingly. |
PrivateOutgoingMap | 28 | |
SubscribedChatRoomConfig | 29 |
The distributed chat protocol is an equivalent of IRC but without a central server.
It uses 6 kind of items:
- ChatRoomEvent
- ChatRoomInvite
- ChatRoomConnectChallenge
- ChatRoomUnsubscribe
- ChatRoomListRequest
- ChatRoomList
When receiving this, send back the list of subscribed rooms, which are any of those:
- public rooms
- private room: where the sender is participating in that room
- private room: where the sender is a previously known peer of that room (rejoin)
- RS: sends a chat room list request each 121 seconds to all peers when there is already some chat rooms available. Otherwise each 20 seconds. (Note: in practice it asks for the list each 20 seconds because of a bug).
- Xeres: sends a chat room list request immediately upon peer connection, then each 120 seconds.
When receiving this:
- process a maximum of 50 chat rooms
For each chat room in the list:
- update the chat rooms with the latest infos
- insert the peer as participating friend in it
- if not in the room already, subscribe to it and send invites to the participating peers
- if already subscribed, send invite
-
do the usual processing like for chat messages (XXX: document it)
-
event type:
- peer_left: remove user from the list
- peer_joined: add user to the list send a keep alive packet to signal our presence to other users
- keep_alive: add user to the list
- search all currently joined chat room messages no older than 35 seconds
- check if any of their challenge code matches
- if yes, add the peer to the list of participating chat room peers (where the message is in) and send an invitation to the chat room
A connection challenge is sent from the cleanup routine to all send_challenge_lobbies. It is done as follows:
- find a recent message from the destination chat room, no older than 30 seconds
- send to all connected peers
- if already in the chat room, add the peer in the chatroom's participating peers
- if not, show a requested inviting us to the room
- if in the chat room, remove peer from participating peers
When wanting to unsubscribe:
- send a PEER_LEFT message
- send a unsubscribe item to all participating peers of the room