Atavism Version 2018.1AGIS API

atavism.server.worldmgr
Class LoginPlugin

java.lang.Object
  extended by atavism.server.engine.EnginePlugin
      extended by atavism.server.worldmgr.LoginPlugin
All Implemented Interfaces:
MessageCallback, StatusMapCallback, TcpAcceptCallback
Direct Known Subclasses:
AgisLoginPlugin

public class LoginPlugin
extends EnginePlugin
implements TcpAcceptCallback

Supports the character selection and creation protocols. The plugin returns a list characters available to the user. Includes character properties and the proxy server host/port for each character.

The user can create a character by supplying a set of character properties. The plugin returns the new character properties or an error if the character could not be created.

LoginPlugin must be sub-classed to implement character selection and creation. A sub-class must implement #handleCharacterRequestMessage(CharacterRequestMessage, SocketChannel) and may implement #handleCharacterCreateMessage(CharacterCreateMessage , SocketChannel , AOByteBuffer) if character creation is supported and #handleCharacterDeleteMessage(CharacterDeleteMessage , SocketChannel , AOByteBuffer) if character deletion is supported. Sub-classes should not need to call any LoginPlugin methods except getCharacterGenerator().

For a sample implementation see atavism.mars.plugins#MarsLoginPlugin


Nested Class Summary
static class LoginPlugin.CharacterCreateMessage
          Message to create a character using the given properties.
static class LoginPlugin.CharacterCreateResponseMessage
          Message to return new character properties.
static class LoginPlugin.CharacterDeleteMessage
          Message to delete a character using the given properties.
static class LoginPlugin.CharacterDeleteResponseMessage
          Message to return new character properties.
static class LoginPlugin.CharacterRequestMessage
          Message to authorize user and get their character list.
static class LoginPlugin.CharacterResponseMessage
          Message to return world token and character list.
static class LoginPlugin.CharacterSelectRequestMessage
          Message to log in as the selected character.
static class LoginPlugin.CharacterSelectResponseMessage
          Message to return access token and hostname/port for selected character.
static class LoginPlugin.HeartbeatMessage
          Message to get the server list.
static class LoginPlugin.HeartbeatResponseMessage
          Message to return world token and server list.
static class LoginPlugin.ServerListRequestMessage
          Message to get the server list.
static class LoginPlugin.ServerListResponseMessage
          Message to return world token and server list.
protected  class LoginPlugin.SocketHandler
           
 
Nested classes/interfaces inherited from class atavism.server.engine.EnginePlugin
EnginePlugin.DeleteHook, EnginePlugin.DeleteSubObjHook, EnginePlugin.GenerateSubObjectHook, EnginePlugin.GetPropertyMessage, EnginePlugin.GetPropertyNamesMessage, EnginePlugin.LoadHook, EnginePlugin.LoadSubObjHook, EnginePlugin.PluginActivateHook, EnginePlugin.PluginStateMessage, EnginePlugin.SaveHook, EnginePlugin.SaveSubObjHook, EnginePlugin.SetPropertyMessage, EnginePlugin.SubObjData, EnginePlugin.TransferFilter, EnginePlugin.TransferObjectMessage, EnginePlugin.UnloadHook, EnginePlugin.UnloadSubObjHook
 
Field Summary
static int LOGIN_IDLE_TIMEOUT
           
static int MSGCODE_CHARACTER_CREATE
           
static int MSGCODE_CHARACTER_CREATE_RESPONSE
           
static int MSGCODE_CHARACTER_DELETE
           
static int MSGCODE_CHARACTER_DELETE_RESPONSE
           
static int MSGCODE_CHARACTER_REQUEST
           
static int MSGCODE_CHARACTER_RESPONSE
           
static int MSGCODE_CHARACTER_SELECT_REQUEST
           
static int MSGCODE_CHARACTER_SELECT_RESPONSE
           
static int MSGCODE_HEARTBEAT
           
static int MSGCODE_HEARTBEAT_RESPONSE
           
static int MSGCODE_SECURE_CHARACTER_REQUEST
           
static int MSGCODE_SERVER_LIST_REQUEST
           
static int MSGCODE_SERVER_LIST_RESPONSE
           
static boolean SecureToken
          The master server sends us the account id in a secure manner by default.
static long TokenValidTime
           
static java.lang.Integer WorldId
          If WorldId is set, the LoginPlugin only accepts master tokens that specify the correct world id.
 
Fields inherited from class atavism.server.engine.EnginePlugin
deleteSubObjectSubscription, dumpAllThreadSubscription, dumpAllThreadSubscriptionLock, loadSubObjectSubscription, lock, MSG_TYPE_DUMP_ALL_THREAD_STACKS, MSG_TYPE_GET_PROPERTY, MSG_TYPE_GET_PROPERTY_NAMES, MSG_TYPE_PLUGIN_STATE, MSG_TYPE_SET_PROPERTY, MSG_TYPE_SET_PROPERTY_NONBLOCK, MSG_TYPE_TRANSFER_OBJECT, pluginStateSubscription, propertySubscription, saveSubObjectSubscription, selectionFilter, selectionSubscription, setSubObjectPersistenceSubscription, subObjectSubscription, unloadSubObjectSubscription
 
Fields inherited from interface atavism.msgsys.MessageCallback
NO_FLAGS, RESPONSE_EXPECTED
 
Constructor Summary
LoginPlugin()
           
 
Method Summary
 void dbConnect()
          This method connects to the database.
static CharacterGenerator getCharacterGenerator()
          Get the global character generator.
 int getTCPPort()
          This method returns the port the login plugin will listen to for incoming tcp connection.
protected  LoginPlugin.CharacterCreateResponseMessage handleCharacterCreateMessage(LoginPlugin.CharacterCreateMessage message, LoginPlugin.SocketHandler clientSocket)
          Respond to a character creation request from the client.
protected  LoginPlugin.CharacterDeleteResponseMessage handleCharacterDeleteMessage(LoginPlugin.CharacterDeleteMessage message, LoginPlugin.SocketHandler clientSocket)
           
protected  LoginPlugin.CharacterResponseMessage handleCharacterRequestMessage(LoginPlugin.CharacterRequestMessage message, LoginPlugin.SocketHandler clientSocket)
          Respond to a character list request message from the client.
protected  LoginPlugin.CharacterSelectResponseMessage handleCharacterSelectRequestMessage(LoginPlugin.CharacterSelectRequestMessage message, LoginPlugin.SocketHandler clientSocket)
           
protected  LoginPlugin.HeartbeatResponseMessage handleHeartbeatMessage(LoginPlugin.HeartbeatMessage message, LoginPlugin.SocketHandler clientSocket)
           
protected  LoginPlugin.ServerListResponseMessage handleServerListRequestMessage(LoginPlugin.ServerListRequestMessage message, LoginPlugin.SocketHandler clientSocket)
           
 void onActivate()
          for developers extending the EnginePlugin object, it may be easier to use the onActivate() method which gets called when the plugin is being activated by the Engine.
 void onTcpAccept(java.nio.channels.SocketChannel clientSocket)
           
protected  PluginStatus selectBestProxy(java.util.List<PluginStatus> plugins, java.util.Map<java.lang.String,java.io.Serializable> characterProperties)
           
protected  PluginStatus selectProxyPlugin(java.util.Map<java.lang.String,java.io.Serializable> characterProperties)
           
protected  boolean setProxyProperties(java.util.Map<java.lang.String,java.io.Serializable> props, PluginStatus proxy)
          Use the information in the plugin status's info field to tell the client what the external address is for the proxy plugin.
 void setTCPPort(int port)
          Set the port the login plugin will listen to for incoming tcp connection.
 
Methods inherited from class atavism.server.engine.EnginePlugin
activate, createMBeanInstance, createSubscription, getHookManager, getMessageHandler, getName, getObjectLockManager, getObjectProperties, getObjectProperties, getObjectProperty, getObjectPropertyNames, getPercentCPULoad, getPluginAvailable, getPluginInfo, getPluginNamespaces, getPluginState, getPluginStatus, getPluginType, getPropertyImpl, getPropertyNamesImpl, getStatusMap, handleMessage, handleMessageImpl, logDepsOutstanding, processKeysAndValues, registerActivateHook, registerDeleteHook, registerLoadHook, registerPluginNamespace, registerPluginNamespaces, registerPluginNamespaces, registerPluginNamespaces, registerSaveHook, registerTransferHook, registerUnloadHook, sendSubObjectResponse, sendSubObjectResponse, sendSubObjectResponse, setMessageHandler, setName, setObjectProperties, setObjectProperties, setObjectProperties, setObjectPropertiesNoResponse, setObjectPropertiesNoResponse, setObjectPropertiesNoResponse, setObjectProperty, setObjectPropertyNoResponse, setPercentCPULoad, setPluginAvailable, setPluginInfo, setPluginType, setPropertyImpl, transferObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSGCODE_CHARACTER_RESPONSE

public static final int MSGCODE_CHARACTER_RESPONSE
See Also:
Constant Field Values

MSGCODE_CHARACTER_DELETE

public static final int MSGCODE_CHARACTER_DELETE
See Also:
Constant Field Values

MSGCODE_CHARACTER_DELETE_RESPONSE

public static final int MSGCODE_CHARACTER_DELETE_RESPONSE
See Also:
Constant Field Values

MSGCODE_CHARACTER_CREATE

public static final int MSGCODE_CHARACTER_CREATE
See Also:
Constant Field Values

MSGCODE_CHARACTER_CREATE_RESPONSE

public static final int MSGCODE_CHARACTER_CREATE_RESPONSE
See Also:
Constant Field Values

MSGCODE_CHARACTER_REQUEST

public static final int MSGCODE_CHARACTER_REQUEST
See Also:
Constant Field Values

MSGCODE_CHARACTER_SELECT_REQUEST

public static final int MSGCODE_CHARACTER_SELECT_REQUEST
See Also:
Constant Field Values

MSGCODE_CHARACTER_SELECT_RESPONSE

public static final int MSGCODE_CHARACTER_SELECT_RESPONSE
See Also:
Constant Field Values

MSGCODE_SECURE_CHARACTER_REQUEST

public static final int MSGCODE_SECURE_CHARACTER_REQUEST
See Also:
Constant Field Values

MSGCODE_SERVER_LIST_REQUEST

public static final int MSGCODE_SERVER_LIST_REQUEST
See Also:
Constant Field Values

MSGCODE_SERVER_LIST_RESPONSE

public static final int MSGCODE_SERVER_LIST_RESPONSE
See Also:
Constant Field Values

MSGCODE_HEARTBEAT

public static final int MSGCODE_HEARTBEAT
See Also:
Constant Field Values

MSGCODE_HEARTBEAT_RESPONSE

public static final int MSGCODE_HEARTBEAT_RESPONSE
See Also:
Constant Field Values

LOGIN_IDLE_TIMEOUT

public static final int LOGIN_IDLE_TIMEOUT
See Also:
Constant Field Values

SecureToken

public static boolean SecureToken
The master server sends us the account id in a secure manner by default. If clients bypass the master server, set this to false. This allows people to masquerade as others and should only be used for development purposes.


TokenValidTime

public static long TokenValidTime

WorldId

public static java.lang.Integer WorldId
If WorldId is set, the LoginPlugin only accepts master tokens that specify the correct world id.

Constructor Detail

LoginPlugin

public LoginPlugin()
Method Detail

dbConnect

public void dbConnect()
This method connects to the database. It assumes the host, user, and port have already been set.


setTCPPort

public void setTCPPort(int port)
Set the port the login plugin will listen to for incoming tcp connection.

Parameters:
port - the port number used for incoming tcp connections

getTCPPort

public int getTCPPort()
This method returns the port the login plugin will listen to for incoming tcp connection.

Returns:
the tcp port number
See Also:
setTCPPort(int)

onActivate

public void onActivate()
Description copied from class: EnginePlugin
for developers extending the EnginePlugin object, it may be easier to use the onActivate() method which gets called when the plugin is being activated by the Engine. this is an alternative to calling registerActivateHook()

Overrides:
onActivate in class EnginePlugin

onTcpAccept

public void onTcpAccept(java.nio.channels.SocketChannel clientSocket)
Specified by:
onTcpAccept in interface TcpAcceptCallback

handleCharacterRequestMessage

protected LoginPlugin.CharacterResponseMessage handleCharacterRequestMessage(LoginPlugin.CharacterRequestMessage message,
                                                                             LoginPlugin.SocketHandler clientSocket)
Respond to a character list request message from the client. The message contains the client's auth token and client version. Implementations should verify the authenticity of the token and return an empty world token if the token is invalid. If the auth token is valid, then LoginPlugin.CharacterResponseMessage.setWorldToken(String) should be set to a non-empty string. This will indicate to the LoginPlugin base class that the user is authorized. The auth token to be passed to subsequent handleCharacterCreateMessage() calls only if the user is authorized.

The auth token should contain (or otherwise supply) the user's identity. The user's characters are returned in a LoginPlugin.CharacterResponseMessage.

Implementations must not read or write data to the clientSocket.

Parameters:
message - request for character list and authorization.
clientSocket - the client's socket connection. Useful for determining the client's source IP and port number. Implementations must not read or write data to the socket.

handleCharacterCreateMessage

protected LoginPlugin.CharacterCreateResponseMessage handleCharacterCreateMessage(LoginPlugin.CharacterCreateMessage message,
                                                                                  LoginPlugin.SocketHandler clientSocket)
Respond to a character creation request from the client. The message contains the desired character properties.

If character creation is successful, the returned CharacterCreateResponseMessage should contain the new character properties. In addition, the response should also contain a Boolean "status" property that is TRUE for success and FALSE for failure. In case of failure, the response should contain a String "errorMessage" property.

Implementations must not read or write data to the clientSocket.


handleCharacterDeleteMessage

protected LoginPlugin.CharacterDeleteResponseMessage handleCharacterDeleteMessage(LoginPlugin.CharacterDeleteMessage message,
                                                                                  LoginPlugin.SocketHandler clientSocket)

handleCharacterSelectRequestMessage

protected LoginPlugin.CharacterSelectResponseMessage handleCharacterSelectRequestMessage(LoginPlugin.CharacterSelectRequestMessage message,
                                                                                         LoginPlugin.SocketHandler clientSocket)

handleServerListRequestMessage

protected LoginPlugin.ServerListResponseMessage handleServerListRequestMessage(LoginPlugin.ServerListRequestMessage message,
                                                                               LoginPlugin.SocketHandler clientSocket)

setProxyProperties

protected boolean setProxyProperties(java.util.Map<java.lang.String,java.io.Serializable> props,
                                     PluginStatus proxy)
Use the information in the plugin status's info field to tell the client what the external address is for the proxy plugin.

Parameters:
props -
proxy -
Returns:

handleHeartbeatMessage

protected LoginPlugin.HeartbeatResponseMessage handleHeartbeatMessage(LoginPlugin.HeartbeatMessage message,
                                                                      LoginPlugin.SocketHandler clientSocket)

getCharacterGenerator

public static CharacterGenerator getCharacterGenerator()
Get the global character generator.


selectProxyPlugin

protected final PluginStatus selectProxyPlugin(java.util.Map<java.lang.String,java.io.Serializable> characterProperties)

selectBestProxy

protected PluginStatus selectBestProxy(java.util.List<PluginStatus> plugins,
                                       java.util.Map<java.lang.String,java.io.Serializable> characterProperties)


Copyright © 2018 Dragonsan Studios Sp. z o.o.