Interface UserSession
- All Superinterfaces:
AttrOptionDynamic
- All Known Implementing Classes:
SocketUserSession
External user session abstraction for one connected client.
- Author:
- 渔民小镇
- See Also:
- date:
- 2023-02-18
-
Method Summary
Modifier and TypeMethodDescriptionvoidemploy(CommunicationMessage message) Adds user info to request.int[]Get logic server bindings associated with this session.getIp()Get the client IP address.getState()Get the current session state.longGets the UserChannelId of the current user (player).longGets the ID of the current user (player).booleanisActive()Check whether the session is active.booleanChecks if the identity has been verified.default CommunicationMessageCreate and populate a communication message for the given route.voidsetAttachment(byte[] attachment) Set the attachment bytes stored on the session.voidsetBindingLogicServerIds(int[] bindingLogicServerIds) Set logic server bindings associated with this session.voidsetExternalJoin(ExternalJoinEnum externalJoin) Set the transport type used by this session.voidsetUserId(long userId) Sets the ID of the current user (player).<T> TwriteAndFlush(Object message) Write a message to the client and flush immediately.Methods inherited from interface AttrOptionDynamic
getOptions, ifNull, ifPresent, option, option, optionValue
-
Method Details
-
isActive
boolean isActive()Check whether the session is active.- Returns:
- true if the session is active
-
setExternalJoin
Set the transport type used by this session.- Parameters:
externalJoin- external transport type
-
setUserId
void setUserId(long userId) Sets the ID of the current user (player).- Parameters:
userId- business user id
-
getUserId
long getUserId()Gets the ID of the current user (player).- Returns:
- current business user id
-
isVerifyIdentity
boolean isVerifyIdentity()Checks if the identity has been verified.- Returns:
- true if logged in
-
getState
-
getUserChannelId
long getUserChannelId()Gets the UserChannelId of the current user (player).- Returns:
- user channel id
-
employ
Adds user info to request. Developers can extend data via HeadMetadata.setAttachmentData(byte[]), which will be forwarded to the logic server.- Parameters:
message- outbound message to enrich with session identity/attachment data
-
writeAndFlush
Write a message to the client and flush immediately.- Parameters:
message- message object- Returns:
- transport-specific future or write result
-
getIp
-
setAttachment
void setAttachment(byte[] attachment) Set the attachment bytes stored on the session.- Parameters:
attachment- attachment bytes
-
setBindingLogicServerIds
void setBindingLogicServerIds(int[] bindingLogicServerIds) Set logic server bindings associated with this session.- Parameters:
bindingLogicServerIds- bound logic server ids
-
getBindingLogicServerIds
int[] getBindingLogicServerIds()Get logic server bindings associated with this session.- Returns:
- bound logic server ids
-
ofMessage
Create and populate a communication message for the given route.- Parameters:
cmdInfo- route metadata- Returns:
- initialized communication message with session identity data
-