You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detailed installation instructions can be found in [INSTALL.md](INSTALL.md).
40
46
41
-
Be advised that due to the addition of `cmp` as a submodule, you now also need to initialize the git submodules required by toxcore. This can be done by cloning the repo with the following command: `git clone --recurse-submodules https://github.com/Toktok/c-toxcore` or by running `git submodule update --init` in the root directory of the repo.
47
+
Be advised that due to the addition of `cmp` as a submodule, you now also need
48
+
to initialize the git submodules required by toxcore. This can be done by
49
+
cloning the repo with the following command:
50
+
`git clone --recurse-submodules https://github.com/Toktok/c-toxcore` or by
51
+
running `git submodule update --init` in the root directory of the repo.
42
52
43
53
In a nutshell, if you have [libsodium](https://github.com/jedisct1/libsodium)
44
54
installed, run:
@@ -74,17 +84,17 @@ if (err_new != TOX_ERR_NEW_OK) {
74
84
}
75
85
```
76
86
77
-
Here, we simply exit the program, but in a real client you will probably want
78
-
to do some error handling and proper error reporting to the user. The `NULL`
87
+
Here, we simply exit the program, but in a real client you will probably want to
88
+
do some error handling and proper error reporting to the user. The `NULL`
79
89
argument given to the first parameter of `tox_new` is the `Tox_Options`. It
80
-
contains various write-once network settings and allows you to load a
81
-
previously serialised instance. See [toxcore/tox.h](tox.h) for details.
90
+
contains various write-once network settings and allows you to load a previously
91
+
serialised instance. See [toxcore/tox.h](tox.h) for details.
82
92
83
93
### Setting up callbacks
84
94
85
-
Toxcore works with callbacks that you can register to listen for certain
86
-
events. Examples of such events are "friend request received" or "friend sent
87
-
a message". Search the API for `tox_callback_*` to find all of them.
95
+
Toxcore works with callbacks that you can register to listen for certain events.
96
+
Examples of such events are "friend request received" or "friend sent a
97
+
message". Search the API for `tox_callback_*` to find all of them.
88
98
89
99
Here, we will set up callbacks for receiving friend requests and receiving
90
100
messages. We will always accept any friend request (because we're a bot), and
Copy file name to clipboardExpand all lines: docs/Group-Chats.md
+76-31Lines changed: 76 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -2,77 +2,122 @@ Group chats.
2
2
3
3
Note: we assume everyone in the chat trusts each other.
4
4
5
-
These group chats work by temporarily adding the 4 "closest" people defined by a distance function
6
-
in group.c in order to form a circle of connected peers. These peers then relay messages to each other.
7
-
8
-
A friend invites another friend to a group chat by sending them an invite packet. The friend either ignores
9
-
the invite or responds with a response packet if he wants to join the chat. The friend invite contains the type
10
-
of groupchat (text only, A/V) the friend is being invited to.
5
+
These group chats work by temporarily adding the 4 "closest" people defined by a
6
+
distance function in group.c in order to form a circle of connected peers. These
7
+
peers then relay messages to each other.
11
8
9
+
A friend invites another friend to a group chat by sending them an invite
10
+
packet. The friend either ignores the invite or responds with a response packet
11
+
if he wants to join the chat. The friend invite contains the type of groupchat
12
+
(text only, A/V) the friend is being invited to.
12
13
13
14
TODO(irungentoo): write more of this.
14
15
15
16
## Protocol
16
17
17
18
Invite packets:
18
-
Invite packet:
19
+
20
+
### Invite packet:
21
+
22
+
```
19
23
[uint8_t id 96][uint8_t id 0][uint16_t group chat number][33 bytes group chat identifier[1 byte type][32 bytes id]]
24
+
```
20
25
21
-
Response packet
26
+
### Response packet
27
+
28
+
```
22
29
[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]]
30
+
```
23
31
32
+
### Peer online packet:
24
33
25
-
Peer online packet:
34
+
```
26
35
[uint8_t id 97][uint16_t group chat number (local)][33 bytes group chat identifier[1 byte type][32 bytes id]]
36
+
```
37
+
38
+
### Peer leave packet:
27
39
28
-
Peer leave packet:
40
+
```
29
41
[uint8_t id 98][uint16_t group chat number][uint8_t id 1]
42
+
```
30
43
31
-
Peer query packet:
44
+
### Peer query packet:
45
+
46
+
```
32
47
[uint8_t id 98][uint16_t group chat number][uint8_t id 8]
48
+
```
49
+
50
+
### Peer response packet:
51
+
52
+
```
53
+
[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]]
54
+
```
33
55
34
-
Peer response packet:
35
-
[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]]
56
+
### Title response packet:
36
57
37
-
Title response packet:
58
+
```
38
59
[uint8_t id 98][uint16_t group chat number][uint8_t id 10][title]
60
+
```
39
61
40
-
Message packets:
62
+
### Message packets:
63
+
64
+
```
41
65
[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]
66
+
```
67
+
68
+
### Lossy Message packets:
42
69
43
-
Lossy Message packets:
70
+
```
44
71
[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]
72
+
```
45
73
46
-
Group chat types:
47
-
0: text
48
-
1: AV
74
+
## Group chat types:
49
75
76
+
- 0: text
77
+
- 1: AV
50
78
51
79
Note: the message number is increased by 1 for each sent message.
52
80
53
-
message ids:
54
-
0 - ping
55
-
sent every ~60 seconds by every peer.
56
-
No data.
81
+
## message ids:
82
+
83
+
### 0 - ping
84
+
85
+
sent every ~60 seconds by every peer. No data.
86
+
87
+
### 16 - new_peer
57
88
58
-
16 - new_peer
59
89
Tell everyone about a new peer in the chat.
90
+
91
+
```
60
92
[uint16_t peer_num][uint8_t 32bytes real public key][uint8_t 32bytes temp DHT public key]
0 commit comments