File: Group-Chats.md

package info (click to toggle)
libtoxcore 0.2.20-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,124 kB
  • sloc: ansic: 75,034; cpp: 4,933; sh: 1,115; python: 651; makefile: 329; perl: 39
file content (123 lines) | stat: -rw-r--r-- 2,640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Group chats.

Note: we assume everyone in the chat trusts each other.

These group chats work by temporarily adding the 4 "closest" people defined by a
distance function in group.c in order to form a circle of connected peers. These
peers then relay messages to each other.

A friend invites another friend to a group chat by sending them an invite
packet. The friend either ignores the invite or responds with a response packet
if he wants to join the chat. The friend invite contains the type of groupchat
(text only, A/V) the friend is being invited to.

TODO(irungentoo): write more of this.

## Protocol

Invite packets:

### Invite packet:

```
[uint8_t id 96][uint8_t id 0][uint16_t group chat number][33 bytes group chat identifier[1 byte type][32 bytes id]]
```

### Response packet

```
[uint8_t id 96][uint8_t id 1][uint16_t group chat number(local)][uint16_t group chat number to join][33 bytes group chat identifier[1 byte type][32 bytes id]]
```

### Peer online packet:

```
[uint8_t id 97][uint16_t group chat number (local)][33 bytes group chat identifier[1 byte type][32 bytes id]]
```

### Peer leave packet:

```
[uint8_t id 98][uint16_t group chat number][uint8_t id 1]
```

### Peer query packet:

```
[uint8_t id 98][uint16_t group chat number][uint8_t id 8]
```

### Peer response packet:

```
[uint8_t id 98][uint16_t group chat number][uint8_t id 9][Repeated times number of peers: [uint16_t peer num][uint8_t 32bytes real public key][uint8_t 32bytes temp DHT public key][uint8_t name length][name]]
```

### Title response packet:

```
[uint8_t id 98][uint16_t group chat number][uint8_t id 10][title]
```

### Message packets:

```
[uint8_t id 99][uint16_t group chat number][uint16_t peer number][uint32_t message number][uint8_t with a value representing id of message][data]
```

### Lossy Message packets:

```
[uint8_t id 199][uint16_t group chat number][uint16_t peer number][uint16_t message number][uint8_t with a value representing id of message][data]
```

## Group chat types:

- 0: text
- 1: AV

Note: the message number is increased by 1 for each sent message.

## message ids:

### 0 - ping

sent every ~60 seconds by every peer. No data.

### 16 - new_peer

Tell everyone about a new peer in the chat.

```
[uint16_t peer_num][uint8_t 32bytes real public key][uint8_t 32bytes temp DHT public key]
```

### 17 - kill_peer

```
[uint16_t peer_num]
```

### 48 - name change

```
[uint8_t name[namelen]]
```

### 49 - groupchat title change

```
[uint8_t title[titlelen]]
```

### 64 - chat message

```
[uint8_t message[messagelen]]
```

### 65 - action (/me)

```
[uint8_t message[messagelen]]
```