Package dev.arbjerg.lavalink.api
Interface ISocketContext
public interface ISocketContext
Represents a WebSocket connection
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classISocketContext.State -
Method Summary
Modifier and Type Method Description voidcloseWebSocket()Closes this WebSocketvoidcloseWebSocket(int closeCode)voidcloseWebSocket(int closeCode, java.lang.String reason)voiddestroyPlayer(long guildId)java.lang.StringgetClientName()IPlayergetPlayer(long guildId)Returns the player of a guild.java.util.Map<java.lang.Long,IPlayer>getPlayers()java.lang.StringgetSessionId()ISocketContext.StategetState()longgetUserId()voidsendMessage(java.lang.Object message)voidsendMessage(org.json.JSONObject message)Deprecated.As of v3.7 Jackson is the preferred way of JSON serialization, usesendMessage(Object)instead.
-
Method Details
-
getSessionId
@NonNull java.lang.String getSessionId()- Returns:
- The session ID of the connection
-
getUserId
long getUserId()- Returns:
- the User ID of the Client.
-
getClientName
@Nullable java.lang.String getClientName()- Returns:
- the name of the Client, or null if it was not specified.
-
getPlayer
Returns the player of a guild. Never returns null.- Parameters:
guildId- the guild the player is associated with- Returns:
- a potentially newly-created player
-
getPlayers
java.util.Map<java.lang.Long,IPlayer> getPlayers()- Returns:
- a read-only map of all players associated by their guild
-
destroyPlayer
void destroyPlayer(long guildId)- Parameters:
guildId- guild for which to remove player state from
-
sendMessage
@Deprecated void sendMessage(org.json.JSONObject message)Deprecated.As of v3.7 Jackson is the preferred way of JSON serialization, usesendMessage(Object)instead.- Parameters:
message- a JSON message to send to the WebSocket client
-
sendMessage
void sendMessage(java.lang.Object message)- Parameters:
message- a message to send to the WebSocket client, it should be compatible with Jackson.
-
getState
ISocketContext.State getState()- Returns:
- the state of the context
-
closeWebSocket
void closeWebSocket()Closes this WebSocket -
closeWebSocket
void closeWebSocket(int closeCode)- Parameters:
closeCode- the close code to send to the client
-
closeWebSocket
void closeWebSocket(int closeCode, java.lang.String reason)- Parameters:
closeCode- the close code to send to the clientreason- the close reason to send to the client
-