2. Chapter 4 Login and Private Message ElectroServer Design Concepts
3. Event Handlers ElectroServer currently allow event handlers to be created for the following event types: Login Logout User Variable─User has updated the EsObject attached to the user object. Room Variable ─User has updated the EsObject attached to the room. Buddy List─User has updated his buddy list (add/edit/delete). Private/Public Messaging─User has sent a message to another entity (room/user).
4.
5. There are three main types of message that can travel in either direction between the client and the server.
6. Requests ─ Objects created by the client and then sent to the server. (LoginRequest)
7. Responses ─ Objects created by the server as a result of a request and then sent to the client. (LoginResponse)
8.
9.
10. MessageType class This class stores static variables that act as a message definition. All messages (requests, responses, events) have a getMessageType() method. The value of it is one of the static variables in this class. ConnectionEvent LoginResponse PrivateMessageEvent ……
11. 連線與登入流程 Main.as: new ConnServer ConnServer.as: 處理連線與登入 Connect: 讀檔取得ip及port,createConnection() Create Login UI: 連線成功後, new LoginScreen(),聆聽是否按下LoginScreen之[login]按鈕 Login: 讀取輸入之帳號名稱並登入伺服器,登入成功後,移除LoginScreen畫面 Send Message: 傳送訊息給自己測試
12. Chapter 4 Login and Private Message Send Private Message
15. Login To log in to ElectroServer, first a LoginRequest object is creted, a username is populated onto that object. var lr:LoginRequest = new LoginRequest(); lr.setUserName(“…”); es.send(lr); Capture the login response that send from server. es.addEventListener(MessageType.LoginResponse, “onLogin”, this);