Class SocketUserSession
java.lang.Object
com.iohao.net.external.core.netty.session.SocketUserSession
- All Implemented Interfaces:
AttrOptionDynamic, UserSession
Netty channel-backed implementation of an external user session.
- Author:
- 渔民小镇
- date:
- 2023-02-18
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected int[]protected io.netty.channel.Channelprotected ExternalJoinEnumprotected intprotected final AttrOptionsprotected UserSessionStateprotected longprotected long -
Method Summary
Modifier and TypeMethodDescriptionvoidemploy(CommunicationMessage message) Adds user info to request.booleanbyte[]int[]Get logic server bindings associated with this session.io.netty.channel.ChannelintgetIp()Get the client IP address.Gets the dynamic member attributes (options)getState()Get the current session state.longGets the UserChannelId of the current user (player).longGets the ID of the current user (player).inthashCode()booleanisActive()Check whether the session is active.booleanChecks if the identity has been verified.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.voidsetExternalServerId(int externalServerId) voidsetState(UserSessionState state) voidsetUserId(long userId) Mark the session as identity-verified when the business user id is assigned.io.netty.channel.ChannelFuturewriteAndFlush(Object message) Write a message to the client and flush immediately.Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AttrOptionDynamic
ifNull, ifPresent, option, option, optionValueMethods inherited from interface UserSession
ofMessage
-
Field Details
-
options
-
channel
protected io.netty.channel.Channel channel -
userId
protected long userId -
userChannelId
protected long userChannelId -
externalServerId
protected int externalServerId -
state
-
externalJoin
-
bindingLogicServerIds
protected int[] bindingLogicServerIds -
attachment
protected byte[] attachment
-
-
Method Details
-
isActive
public boolean isActive()Description copied from interface:UserSessionCheck whether the session is active.- Specified by:
isActivein interfaceUserSession- Returns:
- true if the session is active
-
writeAndFlush
Description copied from interface:UserSessionWrite a message to the client and flush immediately.- Parameters:
message- message object- Returns:
- transport-specific future or write result
-
getIp
-
employ
Description copied from interface:UserSessionAdds user info to request. Developers can extend data via HeadMetadata.setAttachmentData(byte[]), which will be forwarded to the logic server.- Specified by:
employin interfaceUserSession- Parameters:
message- outbound message to enrich with session identity/attachment data
-
setUserId
public void setUserId(long userId) Mark the session as identity-verified when the business user id is assigned.- Specified by:
setUserIdin interfaceUserSession- Parameters:
userId- business user id
-
setBindingLogicServerIds
public void setBindingLogicServerIds(int[] bindingLogicServerIds) Description copied from interface:UserSessionSet logic server bindings associated with this session.- Specified by:
setBindingLogicServerIdsin interfaceUserSession- Parameters:
bindingLogicServerIds- bound logic server ids
-
isVerifyIdentity
public boolean isVerifyIdentity()Description copied from interface:UserSessionChecks if the identity has been verified.- Specified by:
isVerifyIdentityin interfaceUserSession- Returns:
- true if logged in
-
equals
-
hashCode
-
getOptions
Description copied from interface:AttrOptionDynamicGets the dynamic member attributes (options)- Specified by:
getOptionsin interfaceAttrOptionDynamic- Returns:
- The dynamic member attributes
-
getChannel
public io.netty.channel.Channel getChannel() -
getUserId
public long getUserId()Description copied from interface:UserSessionGets the ID of the current user (player).- Specified by:
getUserIdin interfaceUserSession- Returns:
- current business user id
-
getUserChannelId
public long getUserChannelId()Description copied from interface:UserSessionGets the UserChannelId of the current user (player).- Specified by:
getUserChannelIdin interfaceUserSession- Returns:
- user channel id
-
getExternalServerId
public int getExternalServerId() -
getState
Description copied from interface:UserSessionGet the current session state.- Specified by:
getStatein interfaceUserSession- Returns:
- session state
-
getExternalJoin
-
getBindingLogicServerIds
public int[] getBindingLogicServerIds()Description copied from interface:UserSessionGet logic server bindings associated with this session.- Specified by:
getBindingLogicServerIdsin interfaceUserSession- Returns:
- bound logic server ids
-
getAttachment
public byte[] getAttachment() -
setExternalServerId
public void setExternalServerId(int externalServerId) -
setState
-
setExternalJoin
Description copied from interface:UserSessionSet the transport type used by this session.- Specified by:
setExternalJoinin interfaceUserSession- Parameters:
externalJoin- external transport type
-
setAttachment
public void setAttachment(byte[] attachment) Description copied from interface:UserSessionSet the attachment bytes stored on the session.- Specified by:
setAttachmentin interfaceUserSession- Parameters:
attachment- attachment bytes
-