<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[关于Swoole的Client里的$swoole_client = new swoole_client和swoole_client $client是一个值的理解。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Swoole专题研究]]></category>
<pubDate>Thu, 22 Dec 2016 06:53:08 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	核心语句：<br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:38:38<br/>php class 有一些魔术函数你知道吗<br/>回忆未来-向东-Jàck&nbsp;&nbsp;14:39:43<br/>知道<br/>__set __get<br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:43:20<br/>on方法只是注册一些事件<br/>比如close。<br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:44:28<br/>swoole 连接关闭的时候 执行类似于&nbsp;&nbsp;call_user_func($callable, $this, $data);<br/>第一个参数是方法名，我们上面的写法是匿名函数<br/>第二个参数就是对象本身，也就是swoole_client 对象<br/><br/><br/>========================================================<br/><br/>swoole_client_function.php <br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
function swoole_client_function($ip,$port)&#123;
&nbsp;&nbsp;&nbsp;&nbsp;$swoole_client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);

&nbsp;&nbsp;&nbsp;&nbsp;$swoole_client-&gt;on(&quot;connect&quot;, function(swoole_client $client)&nbsp;&nbsp;&#123;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;line81_frame-&gt;id=&quot;.$frame-&gt;fd.&quot;&#92;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$client-&gt;send(json_encode(array(&quot;command&quot; =&gt; $data[&#039;command&#039;],&quot;act&quot;=&gt;$data[&#039;act&#039;], &quot;fd&quot; =&gt; $data[&#039;fd&#039;],&quot;framefd&quot;=&gt;$frame-&gt;fd,&quot;temp&quot;=&gt;$data[&#039;temp&#039;],&quot;status&quot;=&gt;2)));
&nbsp;&nbsp;&nbsp;&nbsp;&#125;);

&nbsp;&nbsp;&nbsp;&nbsp;$swoole_client-&gt;on(&quot;Receive&quot;, function(swoole_client $client, $data) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;File:&quot;.__FILE__.&quot;,Line:&quot;.__LINE__.&quot;,data=&quot;.($data).&quot;&#92;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 操作成功
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;收到TCPServer转述硬件操作成功且包括framefd立即给前端websocket显示下达指令结果。&#92;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$dataArr = json_decode($data,true);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$client-&gt;close();
&nbsp;&nbsp;&nbsp;&nbsp;&#125;);

&nbsp;&nbsp;&nbsp;&nbsp;$swoole_client-&gt;on(&quot;error&quot;, function() &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 操作失败
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;试着连接Server.php里获取硬件温度的旁端口操作失败&#92;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;);

&nbsp;&nbsp;&nbsp;&nbsp;$swoole_client-&gt;on(&quot;close&quot;, function(swoole_client $client) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;$swoole_client-&gt;on(&#92;&quot;Closed&#92;&quot;)短连接关闭掉&#92;n&quot;;

&nbsp;&nbsp;&nbsp;&nbsp;&#125;);

&nbsp;&nbsp;&nbsp;&nbsp;$swoole_client-&gt;connect($ip, $port, -1);
&#125;

swoole_client_function(&quot;101.200.189.210&quot;,&quot;9527&quot;);
swoole_client_function(&quot;101.200.228.135&quot;,&quot;9527&quot;);
?&gt;
</textarea><br/>php swoole_client_function.php <br/>试着连接Server.php里获取硬件温度的旁端口操作失败<br/>试着连接Server.php里获取硬件温度的旁端口操作失败<br/><br/><br/>回忆未来-向东-Jàck&nbsp;&nbsp;14:30:29<br/>感觉$swoole_client-&gt;on(&quot;Receive&quot;, function(swoole_client $client和$swoole_client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);<br/>感觉是传个一个结构体是：swoole_client的，变量不一样，其实是一个东西是吧？兄弟这块哪儿有说呢？<br/>$swoole_client和<br/>function(swoole_client $client ...是一个东西。<br/>这块感觉有啥知识点，兄弟能讲下吗？<br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:31:40<br/>就是一个值传递<br/>回忆未来-向东-Jàck&nbsp;&nbsp;14:32:39<br/>但变量不一样呀，一个是$swoole_client，而另一个变量是，swoole_client $client，它是$client呀，$swoole_client和$client怎么就一样了？<br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:33:33<br/>$a = 1;$b = $a;<br/>$a 和 $b 是不是一样<br/><br/><br/><br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:38:38<br/>php class 有一些魔术函数你知道吗<br/>回忆未来-向东-Jàck&nbsp;&nbsp;14:39:43<br/>知道<br/>__set __get<br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:43:20<br/>on方法只是注册一些事件<br/>比如close。<br/><br/><br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:44:28<br/>swoole 连接关闭的时候 执行类似于&nbsp;&nbsp;call_user_func($callable, $this, $data);<br/>第一个参数是方法名，我们上面的写法是匿名函数<br/>第二个参数就是对象本身，也就是swoole_client 对象<br/>swoole群上海求加入-张振亚-swoole-2345&nbsp;&nbsp;14:45:50<br/>也就是在执行onClose 回调，把本身的client对象传递过来了<br/>你知道他们是同一个对象就行了
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 关于Swoole的Client里的$swoole_client = new swoole_client和swoole_client $client是一个值的理解。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>