`
hacker47
  • 浏览: 336237 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

FLEX提高篇--------客户端呼叫Flash Medis Server3服务端入门

阅读更多

当你不仅仅只想用FLEX来做纯业务数据的管理时,或者当你的项目有视频,音频,多客户端数据或消息同步,数据即时共享,或者你要做网络游戏,互动社区等等更多要求时,学习FMS将刻不容缓,因为FMS是ADOBE为上面一些特定需求而量身定制的服务器,看名字大家都清楚,这里我贴一个应该是最简单的客户端调用FMS服务端函数的例子,比较类似于AJAX的请求与回调,有此经验,应该是一目了然.

 

客户端代码:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center">
	<mx:Script>
		<![CDATA[
			import com.carlcalderon.arthropod.Debug;//导入Debug包
			private var myNc:NetConnection;//定义一个连接对象
			private static const RTMP_URL:String="rtmp://localhost/clientCallServer";//定义RTMP连接地址
			//这里RTMP地址如果是在本地也可以写成rtmp:/clientCallServer,如果是非本地,应该写成rtmp://ip/clientCallServer
			//clientClassServer是你在FMS3安装目录applications目录下新建的一个文件夹名称,也是你的工程的名称,以后所有的东西都放在此目录下
			
			private function sendMsg():void{//定义一个发送消息函数
				myNc=new NetConnection();//实例化一个连接对象
				myNc.connect(RTMP_URL);//连接到远程服务端
				var callbackObject:Responder=new Responder(onResult);//定义回调响应对象
				Debug.log(msg.text);//打印日志
				myNc.call("serverCallFunction",callbackObject,msg.text);
				//调用服务器端serverCallFunction函数,并将返回结果传给callbackObject响应对象,
				//传给服务端serverCallFunction函数的参数为msg.text,这里只传了一个,可以传任意多个
			}
			
			//定义回调函数
			private function onResult(serverBackResult:*):void{
					Debug.log("Server return msg:"+serverBackResult,Debug.BLUE);
					result.text=serverBackResult;//将服务端返回的结果绑定到result TextArea的控件上显示
					msg.text="";//清空输入消息控制msg的值
					try{
						myNc.close();//操作完毕后关闭连接.
					}catch(error:Error){
						Debug.log(error.message.toString(),Debug.GREEN);
					}
				}
			
		]]>
	</mx:Script>
	
	<mx:Label text="Server response Result:"/>
	<mx:TextArea width="300" height="200" id="result"/>
	<mx:HBox>
		<mx:TextInput id="msg" width="300"/>
	</mx:HBox>
	<mx:HBox>
		<mx:Button label="send Message to Server" click="sendMsg();"/>
	</mx:HBox>
</mx:Application>

 

 

服务器端代码:

 

(你要在服务器端你新建的工程目录下clientCallServer里新建一个main.asc文件,然后写在此文件里就行了,就行了,别忘了,代码敲定之后,启动FMS服务器,我前面有文章讲到,这里就不再啰嗦了)

 

 

application.onConnect=function(client){
	trace("come in");
	client.serverCallFunction=function(clientParameter){
		trace(clientParameter+"   come in");
		return "call success!   "+clientParameter;
	}
	
	application.acceptConnection(client);
	
}
/*
	Client.prototype.serverCallFunction=function(clientParameter){
		trace(clientParameter+"come in");;
		return "call success and return back!";
	}
	*/

 

分享到:
评论

相关推荐

    使Redis支持memcached协议medis-server.zip

    基于redis2.0,添加了一个 memcached 端口,支持 memcached 协议。 支持 mc 的 flag 标志,支持 rdb,aof,monitor。 memcached 协议和 redis 协议可以操作同一份数据。... 标签:medis redis

    medis-mac-x64

    medis-mac-x64客户端,直接IP,密码连接即可.非常方便.值得一下

    Medis - GUI for Redis Mac 破解版

    Now you can enjoy Medis with Redis Labs & Azure. 2. Allow duplicating favorites. 3. Change the code font to "Consolas" to make the text clearer. 4. Allow quick connecting by double clicking. 5. ...

    Medis for windows

    Medis --Beautiful Management Application for Redis

    react-Medis是由ElectronReactandRedux搭建的美观易用的Redis数据库管理应用程序

    Medis 是由 Electron, React, and Redux 搭建的美观、易用的 Redis 数据库管理应用程序

    Medis for Mac 1.0.3

    Mac上的redis客户端,根据https://github.com/luin/medis最新的源码编译,1.0.3版本,里面还打包了个M1版本的

    medis破解版(Mac版)

    国内大神的作品,利用medis查看 redis 数据库的优势不用赘述。

    medis for mac(破解)

    redis 可视化工具 medis for mac(破解) Medis是一款非常实用的Redis管理应用工具。软件提供了一些 redis-cli 难以实现的功能,包括创建键副本、修改列表值等,同时你还能够直接读写 JSON 和 MessagePack 格式的数据...

    Medis_0.6_mac.zip

    Medis 是 Mac 系统上一个一款界面很漂亮,而且易于使用的 Redis 数据库管理工具

    Redis-Client.zip

    Redis客户端Medis windows安装包

    Medis.tar.gz

    mac下的一款redis客户端安装包,dmg格式,下载一键安装即可。

    Medis.app.zip

    一个特别好用的redis 客户端工具,简单、大方,使用方便。(直接解压到应用程序中,就可以使用)。来试一试吧,亲们,让我整点积分。好评哦

    MedisForWin

    Medis,这是win版的 https://github.com/x2jia/medis/releases/tag/win https://github.com/x2jia/medis/releases/download/win/MedisForWin171028.exe

    medis 0.6.0

    macos优秀的redis GUI可视化工具,解压即用,喜欢的盆友下载吧。喜欢的盆友下载吧。喜欢的盆友下载吧。

    Redis可视化客户端 下载(Windows版)

    Redis可视化客户端 下载(Windows版) , 下载后解压即可运行使用 ,可视化窗口随时查看相关 值等,简单方便

    Medis for Mac 0.7.1

    超好用的Redis 可视化工具客户端,根据https://github.com/luin/medis最新的源码编译,版本号:0.7.1。开源软件,功能齐全,非破解。仅适用于MacOS,Windows版本的可以自行去github上下载。

    Medis的windows版本

    redis可视化工具。 Medis的windows版本。

    mac系统redis第三方软件medis

    mac端 redis操作第三方软件,支持查询,删除,修改,可视图化,简单操作查看博客https://blog.csdn.net/qq1877383144/article/details/89317167

    Medis_0.6.0_xclient.info.dmg

    Medis 是专为Mac用户设计的一款Redis管理工具,它提供了一些 redis-cli 难以实现的功能,包括创建键副本、修改列表值等,同时你还能够借助 Medis 直接读写 JSON 和 MessagePack 格式的数据,以及读写各种 Redis 配置...

    Medis_0.6.0_xclient.info.dmg.zip

    MacOS系统使用的Redis图形化工具Medis。Medis是一款漂亮易用的Redis GUI管理应用程序。它提供了一些 redis-cli 难以实现的功能,包括创建键副本、修改列表值等,同时你还能够借助 Medis 直接读写 JSON 和 ...

Global site tag (gtag.js) - Google Analytics