<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex the world &#187; 网络电话</title>
	<atom:link href="http://www.flextheworld.com/tag/%e7%bd%91%e7%bb%9c%e7%94%b5%e8%af%9d/feed" rel="self" type="application/rss+xml" />
	<link>http://www.flextheworld.com</link>
	<description>Flex, AIR, FMS, P2P and Things......</description>
	<lastBuildDate>Fri, 06 Aug 2010 01:47:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Call me 更新 &#8212; 简化功能,优化通话效果</title>
		<link>http://www.flextheworld.com/2009/03/call-me-update-simple.html</link>
		<comments>http://www.flextheworld.com/2009/03/call-me-update-simple.html#comments</comments>
		<pubDate>Sat, 14 Mar 2009 10:56:41 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[Call Me]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[Call Me 帮助与技巧]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Plug in]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[博客视频聊天]]></category>
		<category><![CDATA[网络电话]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=447</guid>
		<description><![CDATA[经过半个月的考虑以及与部分用户的讨论，基于博客插件应该使用方便，作用专一的原则，考虑了Call Me的作用及优势是用户可以直接点击博主头像开始视频聊天, 决定对Call Me的功能进行简化。希望大家更喜欢简化后的Call Me，它将与你的博客更好的融合，提供更好的通话效果

点击这里获取你的Call Me博客视频聊天插件
简化前后的界面对比：
简化前

简化后

]]></description>
			<content:encoded><![CDATA[<p>经过半个月的考虑以及与部分用户的讨论，基于博客插件应该使用方便，作用专一的原则，考虑了Call Me的作用及优势是用户可以直接点击博主头像开始视频聊天, 决定对Call Me的功能进行简化。希望大家更喜欢简化后的Call Me，它将与你的博客更好的融合，提供更好的通话效果</p>
<p><img class="alignnone size-full wp-image-465" title="e59bbee78987-4" src="http://www.flextheworld.com/wp-content/uploads/2009/03/e59bbee78987-4.jpg" alt="e59bbee78987-4" width="166" height="178" /><a href="http://www.flextheworld.com/callme-blog-video-chat-plugin" target="_blank"><br />
点击这里获取你的Call Me博客视频聊天插件</a></p>
<p>简化前后的界面对比：<span id="more-447"></span></p>
<h3>简化前</h3>
<p><img class="alignnone size-full wp-image-448" title="old1" src="http://www.flextheworld.com/wp-content/uploads/2009/03/old1.jpg" alt="old1" width="200" height="300" /><img class="alignnone size-full wp-image-453" title="oldb" src="http://www.flextheworld.com/wp-content/uploads/2009/03/oldb.jpg" alt="oldb" width="200" height="300" /></p>
<h3>简化后</h3>
<h3><img class="alignnone size-full wp-image-449" title="e59bbee78987-6-1" src="http://www.flextheworld.com/wp-content/uploads/2009/03/e59bbee78987-6-1.jpg" alt="e59bbee78987-6-1" width="209" height="250" /><img class="alignnone size-full wp-image-451" title="e59bbee78987-14-2" src="http://www.flextheworld.com/wp-content/uploads/2009/03/e59bbee78987-14-2.jpg" alt="e59bbee78987-14-2" width="220" height="250" /><img class="alignnone size-full wp-image-454" title="e59bbee78987-11" src="http://www.flextheworld.com/wp-content/uploads/2009/03/e59bbee78987-11.jpg" alt="e59bbee78987-11" width="220" height="250" /></h3>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/03/call-me-update-simple.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Call Me 更新 &#8212; 允许博客间互相通讯</title>
		<link>http://www.flextheworld.com/2009/03/call-me-update-communicat.html</link>
		<comments>http://www.flextheworld.com/2009/03/call-me-update-communicat.html#comments</comments>
		<pubDate>Sun, 01 Mar 2009 16:37:16 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[Call Me]]></category>
		<category><![CDATA[Call Me 帮助与技巧]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[Plug in]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[博客视频聊天]]></category>
		<category><![CDATA[网络电话]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=410</guid>
		<description><![CDATA[今天为Call Me加入了一项功能,允许博客间互相通讯, 比如博客A和B都装有Call Me, A博客就可以在自己的博客里通过拨号的方式呼叫博客B。
装有Call Me的博客不需要任何手动升级操作，从现在开始刷新页面就会自动更新, 登录后第二个“电话”图标就可以使用了。
下周计划更新好友功能。



]]></description>
			<content:encoded><![CDATA[<p>今天为Call Me加入了一项功能,允许博客间互相通讯, 比如博客A和B都装有Call Me, A博客就可以在自己的博客里通过拨号的方式呼叫博客B。</p>
<p>装有Call Me的博客不需要任何手动升级操作，从现在开始刷新页面就会自动更新, 登录后第二个“电话”图标就可以使用了。</p>
<p>下周计划更新好友功能。</p>
<p><img class="alignnone size-full wp-image-411" title="e59bbee78987-2-1" src="http://www.flextheworld.com/wp-content/uploads/2009/03/e59bbee78987-2-1.jpg" alt="e59bbee78987-2-1" width="222" height="275" /></p>
<p><img class="alignnone size-full wp-image-412" title="1" src="http://www.flextheworld.com/wp-content/uploads/2009/03/1.jpg" alt="1" width="500" height="310" /></p>
<p><img class="alignnone size-full wp-image-414" title="21" src="http://www.flextheworld.com/wp-content/uploads/2009/03/21.jpg" alt="21" width="500" height="317" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/03/call-me-update-communicat.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Call Me 各博客安装教程索引</title>
		<link>http://www.flextheworld.com/2009/02/call-me-blog-install.html</link>
		<comments>http://www.flextheworld.com/2009/02/call-me-blog-install.html#comments</comments>
		<pubDate>Sun, 22 Feb 2009 15:01:15 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[Call Me]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[Call Me 帮助与技巧]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[博客视频聊天]]></category>
		<category><![CDATA[网络电话]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=366</guid>
		<description><![CDATA[
博客视频通讯插件 &#8212; Call Me Wordpress 安装教程
博客视频通讯插件 &#8212; Call Me Blogger 安装教程
博客视频通讯插件 &#8212; Call Me 博客大巴 安装教程
博客视频通讯插件 &#8212; Call Me MySpace 安装教程
博客视频通讯插件 &#8212; Call Me 新浪博客 安装教程

]]></description>
			<content:encoded><![CDATA[<ol>
<li><a href="http://www.flextheworld.com/callme-blog-video-chat-plugin/call-me-wordpress-install" target="_blank">博客视频通讯插件 &#8212; Call Me Wordpress 安装教程</a></li>
<li><a href="http://www.flextheworld.com/callme-blog-video-chat-plugin/call-me-blogger-install" target="_blank">博客视频通讯插件 &#8212; Call Me Blogger 安装教程</a></li>
<li><a href="http://www.flextheworld.com/callme-blog-video-chat-plugin/call-me-blogbus-install" target="_blank">博客视频通讯插件 &#8212; Call Me 博客大巴 安装教程</a></li>
<li><a href="http://www.flextheworld.com/callme-blog-video-chat-plugin/call-me-myspace-install" target="_blank">博客视频通讯插件 &#8212; Call Me MySpace 安装教程</a></li>
<li><a href="http://www.flextheworld.com/callme-blog-video-chat-plugin/call-me-sinablog-install" target="_blank">博客视频通讯插件 &#8212; Call Me 新浪博客 安装教程</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/02/call-me-blog-install.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>新鲜出炉的博客视频通讯插件&#8211;Call Me</title>
		<link>http://www.flextheworld.com/2009/02/blog-videochat-call-me.html</link>
		<comments>http://www.flextheworld.com/2009/02/blog-videochat-call-me.html#comments</comments>
		<pubDate>Sat, 21 Feb 2009 09:49:31 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[Call Me]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[我的事]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Plug in]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[博客视频聊天]]></category>
		<category><![CDATA[网络电话]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=323</guid>
		<description><![CDATA[工作之余写了一款基于P2P技术的博客视频通讯插件(支持视频，语音，短信息)，本来想取名为blogphone,后来一想取这个名字的话插件就局限在博客范围了，实际上它也可以用做网站在线客服，于是左想右想取了Call Me。不过有朋友说这个名字不够有特点。哎，名字难取呀。
Call Me可以支持所有支持Flash插件的博客，目前为止只测试了wordpress，工作正常，这段测试期会尽量测试多的博客，另外修复代码中的Bug。
做Call Me的初衷是方便和家人通话，如果你也碰巧有不太会使用电脑的家人，叫他们到你的博客上和你聊天吧，保证比教他们用QQ或者SKYPY方便得多:) Call Me 可以让访问博客的朋友很方便的与博主联系。
这一版的CallMe提供以下功能
1. 博主自动登陆。
2. 一键呼叫。
3. 短信收发。
4. 视频／音频控制。
5. 一对一聊天。
6. 占线提示。
7. 关闭浏览器自动下线。
8. 博主可以在自己的博客中呼叫其他装有CallMe插件的博主
9. 联系人列表
在以后的版本中会加入更多，更有用的功能，比如一对多的视频。


有兴趣的朋友点击这里获取你的Call Me插件  
]]></description>
			<content:encoded><![CDATA[<p>工作之余写了一款基于P2P技术的博客视频通讯插件(支持视频，语音，短信息)，本来想取名为blogphone,后来一想取这个名字的话插件就局限在博客范围了，实际上它也可以用做网站在线客服，于是左想右想取了Call Me。不过有朋友说这个名字不够有特点。哎，名字难取呀。</p>
<p>Call Me可以支持所有支持Flash插件的博客，目前为止只测试了wordpress，工作正常，这段测试期会尽量测试多的博客，另外修复代码中的Bug。</p>
<p>做Call Me的初衷是方便和家人通话，如果你也碰巧有不太会使用电脑的家人，叫他们到你的博客上和你聊天吧，保证比教他们用QQ或者SKYPY方便得多:) Call Me 可以让访问博客的朋友很方便的与博主联系。</p>
<p>这一版的CallMe提供以下功能</p>
<p>1. 博主自动登陆。<br />
2. 一键呼叫。<br />
3. 短信收发。<br />
4. 视频／音频控制。<br />
5. 一对一聊天。<br />
6. 占线提示。<br />
7. 关闭浏览器自动下线。<br />
8. 博主可以在自己的博客中呼叫其他装有CallMe插件的博主<br />
9. 联系人列表</p>
<p>在以后的版本中会加入更多，更有用的功能，比如一对多的视频。</p>
<p><img class="alignnone size-full wp-image-308" title="main" src="http://www.flextheworld.com/wp-content/uploads/2009/02/main.png" alt="main" width="150" height="203" /><img class="alignnone size-full wp-image-314" title="calling1" src="http://www.flextheworld.com/wp-content/uploads/2009/02/calling1.png" alt="calling1" width="150" height="205" /><img class="alignnone size-full wp-image-311" title="video1" src="http://www.flextheworld.com/wp-content/uploads/2009/02/video1.png" alt="video1" width="150" height="222" /></p>
<p><img class="alignnone size-full wp-image-309" title="calling2" src="http://www.flextheworld.com/wp-content/uploads/2009/02/calling2.png" alt="calling2" width="150" height="209" /><img class="alignnone size-full wp-image-313" title="calling3" src="http://www.flextheworld.com/wp-content/uploads/2009/02/calling3.png" alt="calling3" width="150" height="207" /><img class="alignnone size-full wp-image-315" title="message" src="http://www.flextheworld.com/wp-content/uploads/2009/02/message.png" alt="message" width="150" height="207" /></p>
<p>有兴趣的朋友点击<a href="http://www.flextheworld.com/callme-blog-video-chat-plugin" target="_blank">这里</a>获取你的Call Me插件 <img src='http://www.flextheworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/02/blog-videochat-call-me.html/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Flex 迷你教程 — 基于Stratus的P2P网络电话 (2)</title>
		<link>http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html</link>
		<comments>http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html#comments</comments>
		<pubDate>Sat, 10 Jan 2009 08:53:39 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[FMS]]></category>
		<category><![CDATA[Flex 迷你教程]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[网络电话]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=248</guid>
		<description><![CDATA[接上篇，这一讲里我告诉大家如何链接另一个flash客户端，并且发送文字信息，在下一讲中会引入更多的内容，比如，“是否接收对方呼叫”，“语音和视频的发送” 等等。
看这篇教程时一定要把自己分成“呼叫者”和“被呼叫者”两个身份来看，否者有可能会看得头晕，呵呵。现在我们开始。
1. 首先了解一下我们会用到的变量, 这里要最主要的四个NetStream，他们的作用请看注释。


?View Code ACTIONSCRIPT3//链接Adobe stratus 服务器
private const StratusAddress:String = &#34;rtmfp://stratus.adobe.com&#34;;
&#160;
//Developer Key,如果没有请根据Flex 迷你教程 -- 基于Stratus的P2P网络电话 (1)中的提示申请
private const DeveloperKey:String = &#34;xxxxxx&#34;;
&#160;
//我们需要一个nectConnetion与stratus 服务器链接
private var netConnection:NetConnection;
&#160;
//用于对外发布自己的身份信息流
private var myStream:NetStream;
&#160;
//用于链接后对外发布自己的信息流，比如音频，视频，文字
private var outgoingStream:NetStream;
&#160;
//进入的信息流，这个流对应呼叫者的outgoingStream，用这个流尝试播放发布者发布的信息，比如音频，视频，文字
private var incomingStream:NetStream;
&#160;
//用于尝试播放被呼叫者的身份信息流myStream发送的信息，被呼叫者在发送自己的身份信息流时会监听呼叫者对myStream的播放请求
private var controlStream:NetStream;

2. 下面是主要用到的方法。
呼叫者的主要方法/事件触发顺序，
init()
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:
initSendStream();
call();
onConnectSuccess()
onIm()
被呼叫者主要方法／事件的调用触发顺序
init()
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:
initSendStream();
onPeerConnect();
onIncomingCall();
onIm();
3. Demo (请打开两个浏览器进行Demo) :
操作方法:

任意填写用户名，点击链接。
在另一个浏览器同样登陆。
用其中一个的peerid作为链接ID呼叫对方。
链接成功后可以信息聊天。


4. 源代码下载与主要方法代码，学习请看注释，写的很清楚
输入用户名，点击 “链接”时触发下面的代码

?View Code ACTIONSCRIPT3//链接 adobe stratus 服务器
private function init&#40;&#41;:void&#123;
&#160;
	if&#40;userName.text == &#34;&#34;&#41;
	&#123;
		Alert.show&#40;&#34;请输入任意用户名&#34;,&#34;错误&#34;&#41;
		return
	&#125;
	netConnection = new [...]]]></description>
			<content:encoded><![CDATA[<p>接上篇，这一讲里我告诉大家如何链接另一个flash客户端，并且发送文字信息，在下一讲中会引入更多的内容，比如，“是否接收对方呼叫”，“语音和视频的发送” 等等。</p>
<p>看这篇教程时一定要把自己分成“呼叫者”和“被呼叫者”两个身份来看，否者有可能会看得头晕，呵呵。现在我们开始。</p>
<h2>1. 首先了解一下我们会用到的变量, 这里要最主要的四个NetStream，他们的作用请看注释。</h2>
<p><span id="more-248"></span></p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p248code8'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2488"><td class="code" id="p248code8"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//链接Adobe stratus 服务器</span>
<span style="color: #0033ff; font-weight: bold;">private</span> const StratusAddress<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;rtmfp://stratus.adobe.com&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//Developer Key,如果没有请根据Flex 迷你教程 -- 基于Stratus的P2P网络电话 (1)中的提示申请</span>
<span style="color: #0033ff; font-weight: bold;">private</span> const DeveloperKey<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;xxxxxx&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//我们需要一个nectConnetion与stratus 服务器链接</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> netConnection<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//用于对外发布自己的身份信息流</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> myStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//用于链接后对外发布自己的信息流，比如音频，视频，文字</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> outgoingStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//进入的信息流，这个流对应呼叫者的outgoingStream，用这个流尝试播放发布者发布的信息，比如音频，视频，文字</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> incomingStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//用于尝试播放被呼叫者的身份信息流myStream发送的信息，被呼叫者在发送自己的身份信息流时会监听呼叫者对myStream的播放请求</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> controlStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<h2>2. 下面是主要用到的方法。</h2>
<h3>呼叫者的主要方法/事件触发顺序，</h3>
<p>init()<br />
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:<br />
initSendStream();<br />
call();<br />
onConnectSuccess()<br />
onIm()</p>
<h3>被呼叫者主要方法／事件的调用触发顺序</h3>
<p>init()<br />
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:<br />
initSendStream();<br />
onPeerConnect();<br />
onIncomingCall();<br />
onIm();</p>
<h2>3. Demo (请打开两个浏览器进行Demo) :</h2>
<h3>操作方法:</h3>
<ol>
<li>任意填写用户名，点击链接。</li>
<li>在另一个浏览器同样登陆。</li>
<li>用其中一个的peerid作为链接ID呼叫对方。</li>
<li>链接成功后可以信息聊天。</li>
</ol>
<p><object width="520" height="516" data="http://www.flextheworld.com/flash/P2pPhoneDemo.swf" type="application/x-shockwave-flash"><param name="src" value="http://www.flextheworld.com/flash/P2pPhoneDemo.swf" /></object></p>
<h2>4. 源代码下载与主要方法代码，学习请看注释，写的很清楚</h2>
<h3>输入用户名，点击 “链接”时触发下面的代码</h3>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p248code9'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2489"><td class="code" id="p248code9"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//链接 adobe stratus 服务器</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> == <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;请输入任意用户名&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;错误&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0033ff; font-weight: bold;">return</span>
	<span style="color: #000000;">&#125;</span>
	netConnection = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	netConnection<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> netConnectionHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	netConnection<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span>StratusAddress <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;/&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> DeveloperKey<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//服务器地址里需要开发者Key</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>与stratus链接成功后在case &#8220;NetConnection.Connect.Success&#8221;里调用下面的方法</h3>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p248code10'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24810"><td class="code" id="p248code10"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> initSendStream<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//这三行表示我对外发布一个名称为netConnection.nearID的流，呼叫者通过我的nearID与我链接后，如果播放</span>
	<span style="color: #009900; font-style: italic;">//这个名称为netConnection.nearID的流，会出发onPeerConnect事件，这样我就知道有人链接我</span>
	myStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	myStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> netStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	myStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">.</span>nearID<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//监听onPeerConnect事件</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> o<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	o<span style="color: #000066; font-weight: bold;">.</span>onPeerConnect = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>subscriberStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #009900; font-style: italic;">//当我收到呼叫者的链接请求后，尝试播放呼叫者的流名为&quot;caller&quot;的流，farID代表呼叫者的唯一ID，也就是前面提到的nearID</span>
		<span style="color: #009900; font-style: italic;">//我通过farID找到呼叫者</span>
	    incomingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span>subscriberStream<span style="color: #000066; font-weight: bold;">.</span>farID<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> incomingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;caller&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #009900; font-style: italic;">//监听onIm事件，用于收取文字信息</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span>
        i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">value</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #009900; font-style: italic;">//监听onIncomingCall事件，用于确定链接成功</span>
        i<span style="color: #000066; font-weight: bold;">.</span>onIncomingCall = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
        <span style="color: #000000;">&#123;</span>
        	<span style="color: #009900; font-style: italic;">//显示链接成功后，对呼叫者发布我的信息流，名称为callee</span>
            <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; 已经与你链接<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
            outgoingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;callee&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onConnectSuccess&quot;</span><span style="color: #000066; font-weight: bold;">,</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #000000;">&#125;</span>
        incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	myStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = o<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>呼叫者输入对方Peerid，点击呼叫后执行下面的代码</h3>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p248code11'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24811"><td class="code" id="p248code11"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//通过对方的peerId链接被呼叫者，播放对方的身份信息流</span>
    controlStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span>peerId<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    controlStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> netStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    controlStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>peerId<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//同时对外发布呼叫者的信息流</span>
    outgoingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;caller&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//尝试播放被呼叫者的信息流</span>
    incomingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> peerId<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> incomingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;callee&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;正在呼叫，请稍候...... <span style="">\n</span><span style="">\n</span>&quot;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//监听信息发布事件</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span>
    i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">value</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #009900; font-style: italic;">//监听onConnectSuccess事件，确定链接成功</span>
     i<span style="color: #000066; font-weight: bold;">.</span>onConnectSuccess = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;与&quot;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;链接成功<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #000000;">&#125;</span> 
&nbsp;
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>被呼叫者在收到呼叫时执行</h3>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p248code12'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24812"><td class="code" id="p248code12"><pre class="actionscript3" style="font-family:monospace;">o<span style="color: #000066; font-weight: bold;">.</span>onPeerConnect = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>subscriberStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">//当我收到呼叫者的链接请求后，尝试播放呼叫者的流名为&quot;caller&quot;的流，farID代表呼叫者的唯一ID，也就是前面提到的nearID</span>
	<span style="color: #009900; font-style: italic;">//我通过farID找到呼叫者</span>
    incomingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span>subscriberStream<span style="color: #000066; font-weight: bold;">.</span>farID<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> incomingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;caller&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//监听onIm事件，用于收取文字信息</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span>
    i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">value</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #009900; font-style: italic;">//监听onIncomingCall事件，用于确定链接成功</span>
    i<span style="color: #000066; font-weight: bold;">.</span>onIncomingCall = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
    	<span style="color: #009900; font-style: italic;">//显示链接成功后，对呼叫者发布我的信息流，名称为callee</span>
        <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; 已经与你链接<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
        outgoingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;callee&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onConnectSuccess&quot;</span><span style="color: #000066; font-weight: bold;">,</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>呼叫者与被呼叫者链接成功后执行</h3>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p248code13'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24813"><td class="code" id="p248code13"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//监听onConnectSuccess事件，确定链接成功</span>
i<span style="color: #000066; font-weight: bold;">.</span>onConnectSuccess = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;与&quot;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;链接成功<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>发送信息与接收信息代码</h3>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p248code14'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24814"><td class="code" id="p248code14"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//用outgoingStream对外发布信息流</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
   <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">message</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
    outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onIm&quot;</span><span style="color: #000066; font-weight: bold;">,</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">message</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//监听信息发布事件</span>
<span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span>
i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">value</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h2>源代码</h2>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=4" title="Version0.5 downloaded 1384 times" >P2PhoneDemo1 (1384)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html/feed</wfw:commentRss>
		<slash:comments>108</slash:comments>
		</item>
		<item>
		<title>Flex 迷你教程 &#8212; 基于Stratus的P2P网络电话 (1)</title>
		<link>http://www.flextheworld.com/2009/01/flex-stratus-p2p-phone.html</link>
		<comments>http://www.flextheworld.com/2009/01/flex-stratus-p2p-phone.html#comments</comments>
		<pubDate>Wed, 07 Jan 2009 15:22:17 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[FMS]]></category>
		<category><![CDATA[Flex 迷你教程]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[网络电话]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=226</guid>
		<description><![CDATA[前些天把Adobe官方的p2p Video phone demo的研究了一遍，了解了这个基于Stratus的video phone是如何工作的。由于Adobe的demo需要运行一个python写的web service才可以运行 &#8212; 这个web service用于用户名与peer ID之间的转换，真实项目中我们不可能用256-bit 的 peer ID作为联系人的用户名，所以做一个用户名到Peer ID之间的转换是很用必要的，打电话时只需要知道对方的登陆用户名就可以联系，不需要知道这个超长的不可能记住的Peer ID。可能很多不熟悉python的人没有成功运行源代码，现在我就从我的角度告诉大家如何创建这么一个 P2P 电话。(当然不需要额外的web service)
首先还是了解一些必要的知识
RTMFP &#8212; RTMFP是Adobe公司开发的一套新的通信协议，该协议可以让使用Adobe Flash Player的终端用户之间进行直接通信, RTMFP基于UDP而Flash Media Service支持的RTMP是基于TCP的。
Stratus &#8212; Adobe Stratus service beta 是支持RTMFP 的服务器。它是一个中转式的服务，它的作用是建立flash player之间的通讯。即使它们位于NATs的后面。与FMS不同，Stratus不支持媒体转播，共享对象，脚本等等，你只能开发客户端之间直接联系的应用程序。
我们的网络电话就是基于上面描述的技术，在开始之前有一些准备工作要做。

确定你安装了 Flex SDK3.2. 这里下载
确定安装了flash payer 10 debug version (开发环境最好用debug version)  这里下载
申请一个 Stratus develper key 这里申请
新建一个项目，名字随意，位置随意，编辑项目属性 &#8212; Flex compiler &#8212; Require Flash player version [...]]]></description>
			<content:encoded><![CDATA[<p>前些天把Adobe官方的<a href="http://labs.adobe.com/technologies/stratus/samples/" target="_blank">p2p Video phone demo</a>的研究了一遍，了解了这个基于Stratus的video phone是如何工作的。由于Adobe的demo需要运行一个python写的web service才可以运行 &#8212; 这个web service用于用户名与peer ID之间的转换，真实项目中我们不可能用256-bit 的 peer ID作为联系人的用户名，所以做一个用户名到Peer ID之间的转换是很用必要的，打电话时只需要知道对方的登陆用户名就可以联系，不需要知道这个超长的不可能记住的Peer ID。可能很多不熟悉python的人没有成功运行源代码，现在我就从我的角度告诉大家如何创建这么一个 P2P 电话。(当然不需要额外的web service)<span id="more-226"></span></p>
<h2>首先还是了解一些必要的知识</h2>
<p><strong>RTMFP</strong> &#8212; RTMFP是Adobe公司开发的一套新的通信协议，该协议可以让使用Adobe Flash Player的终端用户之间进行直接通信, RTMFP基于UDP而Flash Media Service支持的RTMP是基于TCP的。</p>
<p><strong>Stratus</strong> &#8212; Adobe Stratus service beta 是支持RTMFP 的服务器。它是一个中转式的服务，它的作用是建立flash player之间的通讯。即使它们位于NATs的后面。与FMS不同，Stratus不支持媒体转播，共享对象，脚本等等，你只能开发客户端之间直接联系的应用程序。</p>
<p>我们的网络电话就是基于上面描述的技术，在开始之前有一些准备工作要做。</p>
<ol>
<li>确定你安装了 Flex SDK3.2. <a href="http://www.adobe.com/products/flex/flexdownloads/" target="_blank">这里下载</a></li>
<li>确定安装了flash payer 10 debug version (开发环境最好用debug version)  <a href="http://www.adobe.com/support/flashplayer/downloads.html" target="_blank">这里下载</a></li>
<li>申请一个 Stratus develper key <a href="https://www.adobe.com/cfusion/entitlement/index.cfm?e=stratus" target="_blank">这里申请</a></li>
<li>新建一个项目，名字随意，位置随意，编辑项目属性 &#8212; Flex compiler &#8212; Require Flash player version 到 10:0:0</li>
<li>安装好上面的东西，然后等我明天来写  “<a href="http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html" target="_blank">基于Stratus的P2P网络电话 (2)</a>”  <img src='http://www.flextheworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/01/flex-stratus-p2p-phone.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
