forked from lavalink-devs/Lavalink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISocketContext.java
More file actions
99 lines (82 loc) · 2.26 KB
/
ISocketContext.java
File metadata and controls
99 lines (82 loc) · 2.26 KB
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
package dev.arbjerg.lavalink.api;
import org.json.JSONObject;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.util.Map;
/**
* Represents a WebSocket connection
*/
public interface ISocketContext {
/**
* @return The session ID of the connection
*/
@NonNull
String getSessionId();
/**
* @return the User ID of the Client.
*/
long getUserId();
/**
* @return the name of the Client, or null if it was not specified.
*/
@Nullable
String getClientName();
/**
* Returns the player of a guild. Never returns null.
*
* @param guildId the guild the player is associated with
* @return a potentially newly-created player
*/
IPlayer getPlayer(long guildId);
/**
* @return a read-only map of all players associated by their guild
*/
Map<Long, IPlayer> getPlayers();
/**
* @param guildId guild for which to remove player state from
*/
void destroyPlayer(long guildId);
/**
* @param message a JSON message to send to the WebSocket client
*
* @deprecated As of v3.7 Jackson is the preferred way of JSON serialization,
* use {@link ISocketContext#sendMessage(Object)} instead.
*/
@Deprecated
void sendMessage(JSONObject message);
/**
* @param message a message to send to the WebSocket client, it should be compatible with Jackson.
*/
void sendMessage(Object message);
/**
* @return the state of the context
*/
State getState();
/**
* Closes this WebSocket
*/
void closeWebSocket();
/**
* @param closeCode the close code to send to the client
*/
void closeWebSocket(int closeCode);
/**
* @param closeCode the close code to send to the client
* @param reason the close reason to send to the client
*/
void closeWebSocket(int closeCode, String reason);
enum State {
/**
* The context has an open WebSocket
*/
OPEN,
/**
* The context does not have an open WebSocket, but can later be resumed
*/
RESUMABLE,
/**
* The WebSocket has closed and this context will never be used again
*/
DESTROYED
}
}