上一篇《FluorineFx + Flex視訊交談室案例開發----伺服器端》詳細的介紹了如何利用 FluorineFx開發一個及時通訊的視訊交談室伺服器處理常式,並通過Web網站來宿主這個服務 處理常式的運行。本篇將著重介紹視訊交談室的用戶端開發,包括串連RTMP伺服器、發布視 頻、接收視頻、線上使用者列表、發送簡訊以及全伺服器小喇叭功能點。
上述這些功能點在我以前寫的文章裡已經出現了N多次了,所以這裡我不想過多的在次對 他們進行解說,詳細請查閱《Flex與.NET互操作系列文章 》,這裡我將核心的幾個方法代碼 貼出來簡單說明。首先就是客戶實現使用者登入,通過FluorineFx提供的RemotingService的接 口方法進行資料驗證。
private function onLogin(event:MouseEvent):void{ remoteConn = new RemotingConnection("http://localhost:2020/ChatRoom.FluorineFxWeb/Gateway.aspx",ObjectEncoding.AMF3); myInfo = new UserInfo(); myInfo.UserName=this.txtUserName.text; myInfo.Password=this.txtPassword.text; remoteConn.RemotingCall("ChatRoom.Services.DataService.Login",onLoginResult,onLoginFault,myInfo);}private function onLoginResult(result:UserInfo):void{ if(result != null) { this.myInfo = result; this.viewStack.selectedChild = chatView; rtmpnc = new RtmpConnection("rtmp://localhost:2777/VideoChat",ObjectEncoding.AMF3,onNetStatusHandler,myInfo); } else { this.lbState.text = "登陸失敗,使用者名稱或密碼錯誤!"; }}private function onLoginFault(event:Object):void{ this.lbState.text = "登陸失敗,請重試!";}private function onClear(event:MouseEvent):void{ this.txtUserName.text=""; this.txtPassword.text=""; this.lbState.text=""; this.txtUserName.setFocus();}