Package live.crowdcontrol.cc4j.websocket
Class ConnectedPlayer
java.lang.Object
live.crowdcontrol.cc4j.websocket.ConnectedPlayer
- All Implemented Interfaces:
WebSocket.Listener,CCPlayer
A player connected to the server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable Stringprotected longprotected final @NotNull EventManagerprotected @Nullable Stringstatic final @NotNull com.fasterxml.jackson.databind.ObjectMapperprotected ScheduledFuture<?> protected @Nullable Stringprotected final ReentrantLockprotected static final @NotNull org.slf4j.Loggerprotected final @NotNull CrowdControlprotected @Nullable CompletableFuture<Void> protected @NotNull StringBuilderprotected intprotected ScheduledFuture<?> protected @Nullable Stringprotected final @NotNull Pathprotected @Nullable UserTokenprotected final @NotNull UUIDprotected @Nullable WebSocket -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanSend()booleanvoidvoidClears the user's auth token if they have one.close()voidconnect()@Nullable StringGets the pending auth code of this connection.@Nullable StringGets the URL for the player to sign in with, if available.@NotNull EventManagerGets the manager which handles distributing events.@Nullable StringGets the ID of the player's active game session.@Nullable StringgetToken()Gets the user's token used for making authenticated requests.@Nullable UserTokenGets the user's profile as decoded from their auth token.@NotNull UUIDgetUuid()Gets the unique ID that represents an in-game player.protected booleanvoidvoidonPong(WebSocket webSocket, ByteBuffer message) onText(WebSocket webSocket, CharSequence data, boolean last) @NotNull CompletableFuture<?> Regenerates the user's auth code.voidprotected voidsendReport(@NotNull CCEffectReport @NotNull ... reports) Sends one or more effect reports to the WebSocket.sendResponse(@NotNull CCEffectResponse response) Sends an effect response to the WebSocket.@NotNull CompletableFuture<?> setCustomEffects(@NotNull List<CustomEffectsOperation> operations) Attempts to set the specified custom effects.boolean@NotNull CompletableFuture<?> startSession(@NotNull CCEffectReport @NotNull ... reports) Attempts to start the streamer's session.@NotNull CompletableFuture<?> Attempts to stop the streamer's session.protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.net.http.WebSocket.Listener
onBinary, onPing
-
Field Details
-
JACKSON
@NotNull public static final @NotNull com.fasterxml.jackson.databind.ObjectMapper JACKSON -
log
@NotNull protected static final @NotNull org.slf4j.Logger log -
lock
-
subscriptions
-
visible
-
available
-
eventManager
-
uuid
-
tokenPath
-
parent
-
pendingText
-
ws
-
authCode
-
token
-
userToken
-
gameSessionID
-
lastGameSessionID
-
pendingAuthCode
-
sleep
protected int sleep -
disconnectTriggeredAt
protected long disconnectTriggeredAt -
keepAlive
-
timeout
-
-
Constructor Details
-
ConnectedPlayer
-
-
Method Details
-
connect
public void connect() -
close
-
clearKeepAlive
public void clearKeepAlive() -
resetKeepAlive
public void resetKeepAlive() -
onPong
- Specified by:
onPongin interfaceWebSocket.Listener
-
onOpen
- Specified by:
onOpenin interfaceWebSocket.Listener
-
onText
- Specified by:
onTextin interfaceWebSocket.Listener
-
onClose
- Specified by:
onClosein interfaceWebSocket.Listener
-
onError
- Specified by:
onErrorin interfaceWebSocket.Listener
-
canSend
public boolean canSend() -
canSendRPC
public boolean canSendRPC() -
sendRPC
-
sendResponse
Description copied from interface:CCPlayerSends an effect response to the WebSocket.- Specified by:
sendResponsein interfaceCCPlayer- Parameters:
response- effect response- Returns:
- whether the response could be sent
-
regenerateAuthCode
Description copied from interface:CCPlayerRegenerates the user's auth code. May fail if the user is already authenticated.- Specified by:
regenerateAuthCodein interfaceCCPlayer- Returns:
- future to complete when the auth code has regenerated
-
sendReport
Description copied from interface:CCPlayerSends one or more effect reports to the WebSocket.- Specified by:
sendReportin interfaceCCPlayer- Parameters:
reports- effect reports- Returns:
- whether the report could be sent
-
setCustomEffects
@NotNull public @NotNull CompletableFuture<?> setCustomEffects(@NotNull @NotNull List<CustomEffectsOperation> operations) Description copied from interface:CCPlayerAttempts to set the specified custom effects. May fail if they have not yet authenticated.- Specified by:
setCustomEffectsin interfaceCCPlayer- Returns:
- future to complete when finished
-
startSession
@NotNull public @NotNull CompletableFuture<?> startSession(@NotNull @NotNull CCEffectReport @NotNull ... reports) Description copied from interface:CCPlayerAttempts to start the streamer's session. May fail if they have not yet authenticated; checkCCPlayer.getGameSessionId()for outcome.- Specified by:
startSessionin interfaceCCPlayer- Returns:
- future to complete when finished
-
stopSession
Description copied from interface:CCPlayerAttempts to stop the streamer's session.- Specified by:
stopSessionin interfaceCCPlayer- Returns:
- future to complete when finished
-
setToken
-
loadToken
protected boolean loadToken() -
saveToken
protected void saveToken() -
subscribe
protected void subscribe() -
getAuthUrl
Description copied from interface:CCPlayerGets the URL for the player to sign in with, if available.- Specified by:
getAuthUrlin interfaceCCPlayer
-
clearToken
public void clearToken()Description copied from interface:CCPlayerClears the user's auth token if they have one. Will not automatically re-generate an auth code; seeCCPlayer.regenerateAuthCode().- Specified by:
clearTokenin interfaceCCPlayer
-
getUuid
Description copied from interface:CCPlayerGets the unique ID that represents an in-game player. -
getAuthCode
Description copied from interface:CCPlayerGets the pending auth code of this connection.- Specified by:
getAuthCodein interfaceCCPlayer- Returns:
- auth code
-
getToken
Description copied from interface:CCPlayerGets the user's token used for making authenticated requests. -
getUserToken
Description copied from interface:CCPlayerGets the user's profile as decoded from their auth token.- Specified by:
getUserTokenin interfaceCCPlayer- Returns:
- user profile
-
getEventManager
Description copied from interface:CCPlayerGets the manager which handles distributing events.- Specified by:
getEventManagerin interfaceCCPlayer
-
getGameSessionId
Description copied from interface:CCPlayerGets the ID of the player's active game session.- Specified by:
getGameSessionIdin interfaceCCPlayer- Returns:
- gameSessionID or null
-