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
Copy file name to clipboardExpand all lines: IMPLEMENTATION.md
+27-64Lines changed: 27 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,31 @@ How to write your own client. The Java client will serve as an example implement
10
10
* Hybi 10
11
11
* Hixie 76
12
12
* Hixie 75
13
+
14
+
## Changes v1.3 -> v2.0
15
+
With the release of v2.0 many unnecessary ops were removed:
16
+
17
+
*`connect`
18
+
*`disconnect`
19
+
*`validationRes`
20
+
*`isConnectedRes`
21
+
*`validationReq`
22
+
*`isConnectedReq`
23
+
*`sendWS`
24
+
25
+
With Lavalink 1.x the server had the responsibility of handling Discord VOICE_SERVER_UPDATEs as well as its own internal ratelimiting.
26
+
This remote handling makes things unnecessarily complicated and adds a lot og points where things could go wrong.
27
+
One problem we noticed is that since JDAA is unaware of ratelimits on the bot's gateway connection, it would keep adding
28
+
to the ratelimit queue to the gateway. With this update this is now the responsibility of the Lavalink client or the
29
+
Discord client.
30
+
31
+
A voice connection is now initiated by forwarding a `voiceUpdate` (VOICE_SERVER_UPDATE) to the server. When you want to
32
+
disconnect or move to a different voice channel you must send Discord a new VOICE_STATE_UPDATE. If you want to move your
33
+
connection to a new Lavalink server you can simply send the VOICE_SERVER_UPDATE to the new node, and the other node
34
+
will be disconnected by Discord.
35
+
36
+
Depending on your Discord library, it may be possible to take advantage of the library's OP 4 handling. For instance,
37
+
the JDA client takes advantage of JDA's websocket write thread to send OP 4s for connects, disconnects and reconnects.
13
38
14
39
## Protocol
15
40
### Opening a connection
@@ -21,16 +46,7 @@ User-Id: The user id of the bot you are playing music with
21
46
```
22
47
23
48
### Outgoing messages
24
-
Make the server queue a voice connection
25
-
```json
26
-
{
27
-
"op": "connect",
28
-
"guildId": "...",
29
-
"channelId": "..."
30
-
}
31
-
```
32
-
33
-
Provide an intercepted voice server update
49
+
Provide an intercepted voice server update. This causes the server to connect to the voice channel
34
50
```json
35
51
{
36
52
"op": "voiceUpdate",
@@ -40,33 +56,6 @@ Provide an intercepted voice server update
40
56
}
41
57
```
42
58
43
-
Close a voice connection
44
-
```json
45
-
{
46
-
"op": "disconnect",
47
-
"guildId": "123"
48
-
}
49
-
```
50
-
51
-
Response to `validationReq`. `channelId` is omitted if the request does not display the channel id.
52
-
```json
53
-
{
54
-
"op": "validationRes",
55
-
"guildId": "...",
56
-
"channelId": "...",
57
-
"valid": true
58
-
}
59
-
```
60
-
61
-
Response to `isConnectedRes`.
62
-
```json
63
-
{
64
-
"op": "isConnectedRes",
65
-
"shardId": 1337,
66
-
"connected": true
67
-
}
68
-
```
69
-
70
59
Cause the player to play a track.
71
60
`startTime` is an optional setting that determines the number of milliseconds to offset the track by. Defaults to 0.
72
61
`endTime` is an optional setting that determines at the number of milliseconds at which point the track should stop playing. Helpful if you only want to play a snippet of a bigger track. By default the track plays until it's end as per the encoded data.
@@ -117,35 +106,9 @@ Set player volume. Volume may range from 0 to 150. 100 is default.
Request to check if the VC or Guild exists, and that we have access to the VC. Note that the channelId may be omitted, in which case you should only check if we are in the guild.
133
-
```json
134
-
{
135
-
"op": "validationReq",
136
-
"guildId": "...",
137
-
"channelId": "..."
138
-
}
139
-
```
140
-
141
-
Request to check if a shard's mainWS is connected
142
-
```json
143
-
{
144
-
"op": "isConnectedReq",
145
-
"shardId": 1337
146
-
}
147
-
```
148
-
149
112
Position information about a player. Includes unix timestamp.
0 commit comments