2008/8/27

Event Handlers

Event handlers are used to implement specific code. All of the available event handlers are covered in the following sections.

Login Event Handler 登入事件

當使用者登入系統時發出,提供完整資訊給開發人員管理使用者登入的情形。可與Multiple login event handler同時執行。 login event handler有能力阻止使用者登入

在LoginEventHandler範例中,使用者連線到伺服器後,並為進入遊戲,透過伺才器幫使用者設定完成。

A login event handler is used to provide custom logic during the login process. The login event handler is designed to allow a developer complete control over how a user logs into the server. Multiple login event handlers can be tied to the server at one time. The order in which they are specified dictates their execution order. Each login event handler has the ability to fail the login at any time. A very common use for a login event handler is to look up a username and password in the database before letting the user login to the server.

See LoginEventHandler in the installation directory/server/examples folder for an example. After creating a login event handler, you will need to use the web admin to add it as a server level component of the extension it is in.

Note that during the executeLogin method, the user is not yet logged in, and not yet in a room. If you need to set a user server variable or permission set for this user, you will need to set it in the context variable.

BaseLoginEventHandler 在doc上的解釋

Custom login event handler. Implement this class, overriding the executeLogin method, and use as a server extension to customize logins. See the LoginEventHandler example plug-in.

Logout Event Handler 登出事件

A logout event handler is used to execute code when the user logs out or disconnects from the server. Unlike the login event handler, these do not work in a chain. Each one is fired in the order specified but with no ties to their peer handlers. A common use for a logout event handler is to track the time the user spent logged in by updating a database with the exit time.

User Variable Event Handler 使用者變數事件

A user variable event handler is used to listen for changes to user variables. It has the ability to perform an action when a user variable is updated, deleted, or created. A good use for this type of handler is to persist the variable to a database table so when a user next logs in, a login event handler can automatically create the user variables for the user.

Buddy List Event Handler

buddy list event handle是用於執行自定羅輯 當使用者新增移除或更新buddy。
與user variable event handler類似,通常用於儲存資料到資料庫中

A buddy list event handler is used to execute custom logic when a user adds, removes, or updates a buddy on their buddy list. Like user variable event handlers, these are most commonly used to store the data to the database. Not yet implemented.

Private Message Event Handler 密文事件

A private message event handler is used to listen for private messages sent between users and is most often used for message logging or custom filtering. Not yet implemented.

Extension Lifecycle Event Handler 擴充生命週期事件

An extension life cycle event handler is a special case event handler that is tied to a given extension, not to the server itself. It listens for both the extension start up and shut down notifications. It is generally used to initially load configuration data for the extension and provide that data to other components in the extension.

Audio/Video Event Handler 影音事件

An audio/video event handler is another multi-purpose event handler. It is used to approve someone attempting to publish or subscribe to a video stream much like a login event handler. It also serves as a notification that a stream has stopped playing or that a user is no longer subscribing.

沒有留言: