FMS案例开发--视频聊天室(二)【转】
?????通过前面的简单分析,下面正式进入视频聊天室的设计开发阶段。根据我以前开发管理软件的经验,我们从基础模块开始,首先设计和开发后台功能模块,实现基本的用户注册和通信接口等相关功能。
??????聊天室需求简单,主要就一张表用来存储用户注册资料,当用户登陆聊天室的时候,则通过通信接口来验证用户。SQL脚本如下:
<?xml?version="1.0"?encoding="utf-8"?>
<mx:TitleWindow?xmlns:mx="http://www.adobe.com/2006/mxml"?layout="absolute"?
????width="400"?height="282"?showCloseButton="true"
????close="closeWindow(event)"?fontSize="12">
????
????<mx:WebService?id="ctService"?wsdl="http://localhost:1535/CRService.asmx?wsdl">
????????<mx:operation?name="Register"?result="onRegisterResult(event)"?fault="onRegisterFaile(event)">
????????</mx:operation>
????</mx:WebService>
????
????<mx:Script>
????????<![CDATA[
????????????import?mx.controls.Alert;
????????????import?flex.chatroom.vo.UserInfo;
????????????import?mx.rpc.events.ResultEvent;
????????????import?mx.managers.PopUpManager;
????????????
????????????private?function?onRegister(evt:MouseEvent):void
????????????
{
????????????????var?info:UserInfo?=?new?UserInfo();
????????????????info.UserName?=?this.txtUserName.text;
????????????????info.Password?=?this.txtPassword.text;
????????????????info.NickName?=?this.txtNickName.text;
????????????????info.QQ?=?this.txtQQ.text;
????????????????var?infos:String=info.UserName+"|"+info.Password+"|"+info.NickName+"|"+info.QQ;
????????????????this.ctService.Register(infos);
????????????}
????????????
????????????private?function?onRegisterResult(evt:ResultEvent):void
????????????
{
????????????????var?result:String?=?evt.result.toString();
????????????????var?arr:Array?=?result.split('|');
????????????????if(arr.length>1)
????????????????
{
????????????????????Alert.okLabel="确?定";
????????????????????Alert.show(arr[1],"系统提示");
????????????????}
????????????????if(arr[0]=="Success")
????????????????
{
????????????????????Alert.okLabel="确?定";
????????????????????Alert.show("恭喜你,注册成功!","系统提示");
????????????????}
????????????????else
????????????????
{
????????????????????Alert.okLabel="确?定";
????????????????????Alert.show("注册失败,请重试!","系统提示");
????????????????}
????????????}
????????????
????????????private?function?onRegisterFaile(evt:Event):void
????????????
{
????????????????Alert.okLabel="确?定";
????????????????Alert.show("注册失败,请重试!","系统提示");
????????????}
????????????
????????????private?function?closeWindow(evt:Event):void
????????????
{
????????????????PopUpManager.removePopUp(this);
????????????}
????????]]>
????</mx:Script>
????
????<mx:Form?y="2"?x="2"?width="99%">
????????<mx:FormHeading?label="新用户注册"/>
????????<mx:FormItem?label="用户名:">
????????????<mx:TextInput?id="txtUserName"?/>
????????</mx:FormItem>
????????<mx:FormItem?label="密??码:">
????????????<mx:TextInput?id="txtPassword"?/>
????????</mx:FormItem>
????????<mx:FormItem?label="呢??称:">
????????????<mx:TextInput?id="txtNickName"?/>
????????</mx:FormItem>
????????<mx:FormItem?label="Q??Q:">
????????????<mx:TextInput?id="txtQQ"?/>
????????</mx:FormItem>
????????<mx:FormItem>
????????????<mx:HBox>
????????????????<mx:Button?label="注?册"?click="onRegister(event)"?fontWeight="normal"?width="95"/>
????????????????<mx:Button?label="取?消"?click="closeWindow(event)"?fontWeight="normal"/>
????????????</mx:HBox>
????????</mx:FormItem>
????</mx:Form>
????
</mx:TitleWindow>
?
??????????????????
?
??????用户登录同样是使用WebService通信进行数据库验证,实现代码大致如下:
??????通信主要就这两个功能点,都比较简单,关于Flex与WebServie通信我以前也写过两篇文章在《Flex与.NET互操作系列文章》里,不熟悉的的朋友可以先看看通信方面的实现。
??????本文就先介绍到这里,下一篇将介绍聊天室的详细开发,包括视频、语音、文字聊天的实现等相关知识点。