<?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>貳夢の弦 &#187; node.js</title>
	<atom:link href="http://blog.frost.tw/tag/node-js/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.frost.tw</link>
	<description>夢醒之時，驚覺一切都是虛幻。前行吧！迷途者。</description>
	<lastBuildDate>Wed, 26 Oct 2011 13:28:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://blog.frost.tw/?pushpress=hub'/>
		<item>
		<title>Socket.IO + Express 生成聊天室</title>
		<link>http://blog.frost.tw/code/poston-2011-10-05/postid-1256</link>
		<comments>http://blog.frost.tw/code/poston-2011-10-05/postid-1256#comments</comments>
		<pubDate>Tue, 04 Oct 2011 16:08:15 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[程式語言]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[程式]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=1256</guid>
		<description><![CDATA[最近又開始研究Node.JS，也因此開始接觸一些 Module 。 （實際上很久之前就接觸了，只是人懶拉……） 這次接觸的是有名的MVC Framework &#8211; Express 和 方便的 Socket.IO 。 說實在的，用來做聊天室真的「非常省時」 （想當初我慢慢寫程式，現在竟然只要半小時……） 大家自己用 NPM 安裝好 Express 後，就用 express -t ejs 生成一個專案吧！ （以下只會針對 Socket.IO 對聊天室製作的程式碼做說明喔！） app.js var io = require("socket.io").listen(app); //app 是 var app = express.createServer(); /* .... 略 &#8230; <a href="http://blog.frost.tw/code/poston-2011-10-05/postid-1256">Continue reading <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>最近又開始研究Node.JS，也因此開始接觸一些 Module 。</p>
<p>（實際上很久之前就接觸了，只是人懶拉……）</p>
<p>這次接觸的是有名的MVC Framework &#8211; Express 和 方便的 Socket.IO 。</p>
<p>說實在的，用來做聊天室真的「非常省時」</p>
<p>（想當初我慢慢寫程式，現在竟然只要半小時……）</p>
<p><span id="more-1256"></span></p>
<p>大家自己用 NPM 安裝好 Express 後，就用 express -t ejs 生成一個專案吧！</p>
<p>（以下只會針對 Socket.IO 對聊天室製作的程式碼做說明喔！）</p>
<p><strong> app.js </strong></p>
<pre class="brush:js">var io = require("socket.io").listen(app); //app 是 var app = express.createServer();

/* .... 略 .... */
app.listen(3000);

//Chat Room
var onlineList = {}; //建立一個線上列表物件

io.sockets.on('connection', function(socket){ //照官方的處理，基本上就是當Clinet連線時要做的事情

  socket.emit('reqNickname'); //向Client要求暱稱（其實應該用 join 而不是這樣，因為這樣會造成一些問題）
  socket.on('setNickname', function(nickname){ //當Client設定暱稱時
    if(!onlineList[nickname]){ //檢查暱稱是否重複
      socket.set('nickname', nickname, function(){ //Socket.IO 支援類似 Session 的儲存，這邊用來紀錄使用者暱稱
        onlineList[nickname] = socket; //這邊把 socket 物件存進去，用於之後的 Private Message 功能（Socket.IO 的每個 socket 都是對應個別 Client 的，不能搞混）
        socket.broadcast.emit('system', {'msg' : '<strong>' + nickname + '</strong> join!'}); //使用Broadcast可以發給除了自己外全部的Client (通知某使用者加入聊天室)
        socket.emit('ready'); //告訴Client可以開始聊天（此時發訊息等才會解鎖，本範例沒有特別限制）
      });
    }else{
      socket.emit('reqNickname'); //如果暱稱存在，則重新要求暱稱
    }
  });

  socket.on('chat', function(data){ //當Client發送聊天訊息
    socket.get('nickname', function(err, nickname){ //先取得暱稱
      if(!err){ //檢查是否有發生錯誤
        if(data.indexOf('/pm ') === 0){ //檢查是否為 /pm 的開頭，如果是判定為「私訊」
          var receiver = data.substr(4); //切割字串
          receiver = receiver.substr(0, receiver.indexOf(' ')); //取得收訊人的暱稱
          var chatMsg = data.substr(receiver.length + 5); //把剩下文字當要傳送的訊息
          if(onlineList[receiver]){ //檢查接收者是否存在
            onlineList[receiver].emit('pm', {'nickname' : nickname, 'msg' : chatMsg, 'rec' : receiver}); //發送給接收者私訊
            socket.emit('pm', {'nickname' : nickname, 'msg' : chatMsg, 'rec' : receiver}); //對Client也發送一次
          }else{
            socket.emit('system', {'msg' : '<strong>' + receiver + '</strong> not found.'});  //接收者不存在則出現錯誤訊息
          }
        }else{
          //一般情況正常聊天
          socket.broadcast.emit('chat', {'nickname' : nickname, 'msg' : data});
          socket.emit('chat', {'nickname' : nickname, 'msg' : data});
        }
      }
    });
  });

  socket.on('disconnect', function(){ //使用者斷開（系統）
    socket.get('nickname', function(err, nickname){ //先取得暱稱
      if(!err){
        if(onlineList[nickname]){ //確認是否存在使用者
          socket.broadcast.emit('system', {'msg' : '<strong>' + nickname + '</strong> exit.'}); //發送系統訊息告知其他使用者Client離線
        }
      }
    });
  });
});</pre>
<p><strong> index.ejs </strong></p>
<p>這邊用 jQuery 輔助，沒有做版面排版（CSS則略，因為除了設定 overflow:hide 之外其他沒有特別設定）</p>
<pre class="brush:html">&lt;script src="/socket.io/socket.io.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;h1&gt;&lt;%= title %&gt;&lt;/h1&gt;
&lt;p&gt;Welcome to &lt;%= title %&gt;&lt;/p&gt;

&lt;div id="chatArea"&gt;

&lt;/div&gt;
&lt;div id="chatForm"&gt;
	&lt;form action="" method="post" name="charForm" id="chat"&gt;
		&lt;span id="nickname"&gt;Unknow&lt;/span&gt; :
		&lt;input type="text" name="message" size="50" id="message" /&gt;
		&lt;input type="submit" name="send" value="Send" id="send" /&gt;
	&lt;/form&gt;
&lt;/div&gt;

&lt;script type="text/javascript"&gt;

    function scrollChatArea()
    {

    }

	var socket = io.connect("dmd.frost.tw", {'port':3030});

	var nickname = "Unknow";

	socket.on('reqNickname', function(){
		nickname = prompt('Type your nickname', '');
		socket.emit('setNickname', nickname);
	});

	socket.on('ready', function(){
		$("#nickname").html("&lt;strong&gt;" + nickname + "&lt;/strong&gt;");
		$("#chat").submit(function(e){

			var msg = $('input[name="message"]').val();
			socket.emit('chat', msg);
			$('input[name="message"]').val('').focus();

			return false;

		});
	});

	socket.on('chat', function(data){
		$("&lt;div&gt;&lt;strong&gt;" + data.nickname + "&lt;/strong&gt; Says: " + data.msg + "&lt;/div&gt;").hide().appendTo("#chatArea").fadeIn();
		$("#chatArea").scrollTop( $("#chatArea").innerHeight() );
	});

    socket.on('system', function(data){
    	$("&lt;div&gt;&amp;gt; " + data.msg + "&lt;/div&gt;").hide().appendTo("#chatArea").fadeIn();
		$("#chatArea").scrollTop( $("#chatArea").innerHeight() );
	});

    socket.on('pm', function(data){
        $("&lt;div&gt;&lt;strong&gt;" + data.nickname + "&lt;/strong&gt; to &lt;strong&gt;" + data.rec + "&lt;/strong&gt; Says: " + data.msg + "&lt;/div&gt;").hide().appendTo("#chatArea").fadeIn();
    	$("#chatArea").scrollTop( $("#chatArea").innerHeight() );
    });

&lt;/script&gt;</pre>
<p>前端使用方法和後端大同小異，都是用 on 和 emit 處理。<br />
如此一來，就完成一個有 PM 功能的聊天室了！<br />
（其實 Socket.IO 還支援 Room 的概念，只要把 Client 用 .join(&#8216;room name&#8217;) 就可以了！）<br />
有不清楚的部份請告知一下，我會解釋……<br />
（這篇文章就針對Server-Side做解釋而已，其他有問題還是可以問的～）</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-10-05%2Fpostid-1256">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/code/poston-2011-10-05/postid-1256/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JSApp.US &#8211; 免費的 Node.JS 伺服器</title>
		<link>http://blog.frost.tw/code/poston-2011-03-07/postid-1141</link>
		<comments>http://blog.frost.tw/code/poston-2011-03-07/postid-1141#comments</comments>
		<pubDate>Mon, 07 Mar 2011 10:58:15 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[程式語言]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[網站]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=1141</guid>
		<description><![CDATA[前幾天，弦也注意到 Node.JS 的 Wiki 上 Hosting 的列表又多了些。 抑或是說這次弦也仔細去閱讀這個列表，發現 JSApp.US 是唯一一個目前可以使用的 Node.JS Hosting 不過，什麼是 Node.JS 大家可能會不解。 以弦也最近更新的知識，他應該是一個 Server Side JavaScript 而且支援 Evented I/O 的程式語言。 那 Node.JS 可以做什麼呢？ 此時，就要舉大家介紹 Node.JS 最常提到的一個網站 &#8211; Plurk 了！ 噗浪就是使用 Node.JS 開發的喔！ 也因此，他擁有即時更新的功能。 這就是所謂的 Comet 技術實踐吧！ 不過，所謂的 &#8230; <a href="http://blog.frost.tw/code/poston-2011-03-07/postid-1141">Continue reading <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>前幾天，弦也注意到 Node.JS 的 Wiki 上 Hosting 的列表又多了些。<br />
抑或是說這次弦也仔細去閱讀這個列表，發現 JSApp.US 是唯一一個目前可以使用的 Node.JS Hosting</p>
<p>不過，什麼是 Node.JS 大家可能會不解。<br />
以弦也最近更新的知識，他應該是一個 Server Side JavaScript 而且支援 Evented I/O 的程式語言。<br />
<span id="more-1141"></span><br />
那 Node.JS 可以做什麼呢？<br />
此時，就要舉大家介紹 Node.JS 最常提到的一個網站 &#8211; Plurk 了！<br />
噗浪就是使用 Node.JS 開發的喔！</p>
<p>也因此，他擁有即時更新的功能。<br />
這就是所謂的 Comet 技術實踐吧！</p>
<p>不過，所謂的 Comet 又是什麼呢？<br />
簡單說，就是利用 Ajax 來做 Socket 的事情。<br />
我們又以 Client 和 Server 分為 Poll 和 Push 兩個動作。<br />
Push 是以伺服器發訊息給客戶端，以往都是被動。<br />
而 Poll 是客戶端請求資料，過去時代的聊天室就是重複 Poll 了！</p>
<p>現在利用 Ajax 模擬 Http 請求，對伺服器做 Poll (Long)<br />
而 Node.JS 則檢查是否有資料，有資料時才做 Push 回去給客戶端。<br />
（因為 Ajax 特性，沒有回應時就不會觸發事件，可以一直等待回應。）</p>
<p>而這樣一來一往的動作，就很類似 Socket 的 Listen Request 之類的動做。<br />
這種技術則稱為 Comet 技術。</p>
<p>Node.JS 則是非常適合用於實踐這個技術的 Server Side 語言。</p>
<p>那麼，回到正題。</p>
<p><strong>JSApp.US 網站資料</strong><br />
網址：<a href="http://jsapp.us" target="_blank">http://jsapp.us<br />
</a>運行模式：VM處理（用戶程式跑在 Child Porcess 中，不干預主程式）<br />
限制：部份 Module 無法載入，http modules 有限使用（createServer&amp;Client都只能用 Port 80）<br />
費用：無（如果想租VPS可以參考開發者的推薦連結，讓這個服務繼續下去。）</p>
<p>那麼，期待大家的作品摟！</p>
<p>官方聊天室範例（使用 node-router 模組 *此為額外擴充）<br />
<a href="http://chat.jsapp.us" target="_blank">http://chat.jsapp.us</a></p>
<p>弦也測試的聊天室（自行處理 Router）<br />
<a href="http://jsapp.frost.tw/" target="_blank">http://jsapp.frost.tw/</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/code/poston-2011-03-07/postid-1141/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>才…才不會讓你看全部呢！</title>
		<link>http://blog.frost.tw/code/poston-2010-11-08/postid-820</link>
		<comments>http://blog.frost.tw/code/poston-2010-11-08/postid-820#comments</comments>
		<pubDate>Mon, 08 Nov 2010 10:55:48 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[程式語言]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[程式]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=820</guid>
		<description><![CDATA[無奸不成商，不會掰不是部落客！ 很好，經過昨天邪惡、強大的實驗，今天也要來唬唬大家（咦 難得學校補假天氣好，好日子不配上好程式怎行呢？ 網友贊助主機當運行平台，不好好開發怎麼行呢？ 所以，今天的 Node.js 寫得特別順！ （以上純屬想像……） 今天的開發有點類似將 Node.js 從一般的聊天室應用，改良成大型聊天室。 要形容的話，就是增加了 Room 的概念。 只要經過 addRoom 方法，指定一個 Room Name 傳入。 那麼，你就可以創建一個聊天室了！ 當然，運行速度有V8保證，絕對不慢。 （說真的用JavaScript運行起來真的「快」阿！） 不過，這個開發果然「瘋狂」 因為這是一整個「物件導向」式的做法。 雖然這家伙根本沒有在認真用物件導向…… 待會看了程式碼，你會怎麼想？ 不過，使用物件確實有點高難度。 而且身為神奇的開發者，竟然在今天才發現加上 new 修飾後，就是個物件…… （果然是基本功沒練好就上場的瘋子……） 廢話不多說，來看看程式碼吧！ 但是，我才…才…才不會讓你看完整哩！ 你們看看，好長一條阿！ 沒錯，兇手就是他！！ 這是將聊天室模組化的成果，充滿了奇蹟（誤 使用方法也很簡單，先是用 Node.js 的 &#8230; <a href="http://blog.frost.tw/code/poston-2010-11-08/postid-820">Continue reading <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Node.js 的 Comet Chat" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/05/01/7198340.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用 Node.js 寫聊天室的心得～" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="邪門Google運用 – JavaScript 留言板" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-05-29%2Fpostid-1199&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/05/29/10022133.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">邪門Google運用 – JavaScript 留言板</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Node.js 上的 MySQL" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>無奸不成商，不會掰不是部落客！<br />
很好，經過昨天邪惡、強大的實驗，今天也要來唬唬大家（咦</p>
<p>難得學校補假天氣好，好日子不配上好程式怎行呢？<br />
網友贊助主機當運行平台，不好好開發怎麼行呢？</p>
<p>所以，今天的 Node.js 寫得特別順！<br />
（以上純屬想像……）<br />
<span id="more-820"></span><br />
今天的開發有點類似將 Node.js 從一般的聊天室應用，改良成大型聊天室。<br />
要形容的話，就是增加了 Room 的概念。<br />
只要經過 addRoom 方法，指定一個 Room Name 傳入。<br />
那麼，你就可以創建一個聊天室了！</p>
<p>當然，運行速度有V8保證，絕對不慢。<br />
（說真的用JavaScript運行起來真的「快」阿！）</p>
<p>不過，這個開發果然「瘋狂」<br />
因為這是一整個「物件導向」式的做法。<br />
雖然這家伙根本沒有在認真用物件導向……<br />
待會看了程式碼，你會怎麼想？</p>
<p>不過，使用物件確實有點高難度。<br />
而且身為神奇的開發者，竟然在今天才發現加上 new 修飾後，就是個物件……<br />
（果然是基本功沒練好就上場的瘋子……）</p>
<p>廢話不多說，來看看程式碼吧！<br />
但是，我才…才…才不會讓你看完整哩！<br />
<a href="http://blog.frost.tw/wp-content/uploads/2010/11/2010-11-08-18-24-38.png" rel="lightbox[820]" title="Node.js - nChat.js"><img class="alignnone size-medium wp-image-821" title="Node.js - nChat.js" src="http://blog.frost.tw/wp-content/uploads/2010/11/2010-11-08-18-24-38-59x300.png" alt="" width="59" height="300" /></a></p>
<p>你們看看，好長一條阿！<br />
沒錯，兇手就是他！！</p>
<p>這是將聊天室模組化的成果，充滿了奇蹟（誤</p>
<p>使用方法也很簡單，先是用 Node.js 的 require 把他引入。</p>
<pre class="brush: js">var chat = require("./chat.js");
chat.addRoom("general");
chat.listen(80);
</pre>
<p>接著，神奇的事情就發生拉！！！<br />
那就是，你打不開網頁……</p>
<p>為什麼？<br />
因為沒有寫 Client 端阿！<br />
現在邪惡的開發者竟然用當年測試Node.js的簡易Client接收訊息。<br />
（到底是怎麼將兩個完全不合的程式組起來，也是很神秘的……當年似乎是幾個月前……）</p>
<p>那麼，你準備好試用了嗎？<br />
當開發者心血來潮之時，你就可以用了！</p>
<p>期待嗎？<br />
請關注「才…才不會讓你看（羞）」系列！<br />
（喔！沒有這東西……）</p>
<p>如果想知道更多，請關注本網誌很糟糕的標題，因為很糟糕，所以看到內容會很失望。<br />
讓你最失望的，一定就是網址。<br />
「所以，請關注下一張圖片！？」</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Node.js 的 Comet Chat" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/05/01/7198340.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用 Node.js 寫聊天室的心得～" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="邪門Google運用 – JavaScript 留言板" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-05-29%2Fpostid-1199&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/05/29/10022133.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">邪門Google運用 – JavaScript 留言板</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Node.js 上的 MySQL" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/code/poston-2010-11-08/postid-820/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.js 的 Comet Chat</title>
		<link>http://blog.frost.tw/code/poston-2010-10-30/postid-800</link>
		<comments>http://blog.frost.tw/code/poston-2010-10-30/postid-800#comments</comments>
		<pubDate>Sat, 30 Oct 2010 11:13:58 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[程式語言]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[程式]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=800</guid>
		<description><![CDATA[今天幫朋友把 Comet Chat 的雛型大致上都做出來了！ 其實也是可以直接上戰場，不過還有點缺陷。 像是 Server Time 比 Client Time 還大時，就會慘遭洗頻…… 不過我想訪客都中原標準時間，應該不會有事（喂 來張測試時的玉照。 因為使用了 jQuery UI 的加持，整個威能很大。 不過，因為時間有限…… （畢竟我摸了一整天，社刊的收尾還沒弄） 很多調整都不能加上，像是調整聊天視窗大小、時間校正、指令功能等等。 不過，目前也是有「支援」的指令喔！ 那就是「/nick 暱稱」指令，可以替換暱稱。 之後我想我會陸續加入各種功能吧…… 不過，在這之前還有一大堆任務得完成。 如網誌改版、社刊、同人社團Amber Clover網站製作等等。 希望下次我有很大威能可以「強化」這款聊天室。 &#62; 經過這次經驗，我可以說是對 Real Time WebGame的雛型有個概念了呢！<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">才…才不會讓你看全部呢！</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>今天幫朋友把 Comet Chat 的雛型大致上都做出來了！<br />
其實也是可以直接上戰場，不過還有點缺陷。</p>
<p>像是 Server Time 比 Client Time 還大時，就會慘遭洗頻……</p>
<p>不過我想訪客都中原標準時間，應該不會有事（喂<br />
<span id="more-800"></span><br />
<a href="http://blog.frost.tw/wp-content/uploads/2010/10/2010-10-30-19-08-53.png" rel="lightbox[800]" title="AR測試中玉照"><img class="alignnone size-medium wp-image-801" title="AR測試中玉照" src="http://blog.frost.tw/wp-content/uploads/2010/10/2010-10-30-19-08-53-300x204.png" alt="" width="300" height="204" /></a></p>
<p>來張測試時的玉照。<br />
因為使用了 jQuery UI 的加持，整個威能很大。</p>
<p>不過，因為時間有限……<br />
（畢竟我摸了一整天，社刊的收尾還沒弄）<br />
很多調整都不能加上，像是調整聊天視窗大小、時間校正、指令功能等等。</p>
<p>不過，目前也是有「支援」的指令喔！<br />
那就是「/nick 暱稱」指令，可以替換暱稱。</p>
<p>之後我想我會陸續加入各種功能吧……</p>
<p>不過，在這之前還有一大堆任務得完成。<br />
如網誌改版、社刊、同人社團Amber Clover網站製作等等。</p>
<p>希望下次我有很大威能可以「強化」這款聊天室。<br />
&gt; 經過這次經驗，我可以說是對 Real Time WebGame的雛型有個概念了呢！</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-11-08%2Fpostid-820&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">才…才不會讓你看全部呢！</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/code/poston-2010-10-30/postid-800/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.js 上的 MySQL</title>
		<link>http://blog.frost.tw/life/poston-2010-07-12/postid-585</link>
		<comments>http://blog.frost.tw/life/poston-2010-07-12/postid-585#comments</comments>
		<pubDate>Mon, 12 Jul 2010 10:55:23 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[生活雜記]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=585</guid>
		<description><![CDATA[昨天寫完聊天室之後，今天就是進行 Web Game 撰寫了！ 因為 Node.js 沒有明確支援哪種資料庫，可用的大概只有檔案讀寫。 為了處理這種問題，很多人開發了 Module 去支援。 但是很可惜，目前我所知的兩種MySQL模組都不適合。 在探索 Comet 技術中，我想 Node.js 可能和我非常合得來。 再加上其也是備受推薦的語言，因此算是容易上手和好用吧！ 不過，他卻有個惱人的問題。 基本支援不多，相較習慣 PHP 的人，在 Node.js 可能會感覺有點辛苦。 （畢竟 PHP 擁有大量的函式支援，很多功能可以輕而易舉做到。） 那麼該如何連接MySQL呢？ 我想，沒有其他選擇了！ 只能使用 Node.js 內建的 Net 模組（ Socket 相關）來手動連接。 當然，在這之前要先確認是否有高手做出模組。 很幸運的，在官方模組列表上有兩款。 （如果我沒看錯，應是有兩款。） 我選了一款名為 Node-MySQL &#8230; <a href="http://blog.frost.tw/life/poston-2010-07-12/postid-585">Continue reading <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">JSApp.US – 免費的 Node.JS 伺服器</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>昨天寫完聊天室之後，今天就是進行 Web Game 撰寫了！<br />
因為 Node.js 沒有明確支援哪種資料庫，可用的大概只有檔案讀寫。<br />
為了處理這種問題，很多人開發了 Module 去支援。<br />
但是很可惜，目前我所知的兩種MySQL模組都不適合。<br />
<span id="more-585"></span><br />
在探索 Comet 技術中，我想 Node.js 可能和我非常合得來。<br />
再加上其也是備受推薦的語言，因此算是容易上手和好用吧！</p>
<p>不過，他卻有個惱人的問題。<br />
基本支援不多，相較習慣 PHP 的人，在 Node.js 可能會感覺有點辛苦。<br />
（畢竟 PHP 擁有大量的函式支援，很多功能可以輕而易舉做到。）</p>
<p>那麼該如何連接MySQL呢？<br />
我想，沒有其他選擇了！<br />
只能使用 Node.js 內建的 Net 模組（ Socket 相關）來手動連接。</p>
<p>當然，在這之前要先確認是否有高手做出模組。<br />
很幸運的，在官方模組列表上有兩款。<br />
（如果我沒看錯，應是有兩款。）</p>
<p>我選了一款名為 Node-MySQL 的模組使用。<br />
（後來發現另一組，不過看起來似乎不堪使用呢！）</p>
<p>當我興致勃勃的將 Web Game 的基礎結構製作好。<br />
（其實就只是登出和登入兩個動作而已……）<br />
我就馬上測試（其實寫太多 Bug 也跟著多，而且也有上百行了……）</p>
<p>很可惜，我自身的錯誤處理完畢後。<br />
竟然是 Node-MySQL 的錯誤，仔細一看，卻發現似乎是自己的失誤。</p>
<p>不過，當我成功連上資料庫時。<br />
卻碰上「無法查詢」的窘境……</p>
<p>總而言之，那Ajax連接就這麼持續到超時斷開。</p>
<p>也許，該換個方法處理吧！<br />
（目前正在考慮檔案讀寫，不過可能會比較吃資源的樣子……）</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">JSApp.US – 免費的 Node.JS 伺服器</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/life/poston-2010-07-12/postid-585/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用 Node.js 寫聊天室的心得～</title>
		<link>http://blog.frost.tw/code/poston-2010-07-11/postid-583</link>
		<comments>http://blog.frost.tw/code/poston-2010-07-11/postid-583#comments</comments>
		<pubDate>Sun, 11 Jul 2010 11:06:23 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[程式語言]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=583</guid>
		<description><![CDATA[就我看來，用 Node.js 比 Ajax Push Engine 困難很多。 不過，做出來的東西不論是自由度或者延展性，真的「好很多！」 雖然目前自己寫的 Chat Room 出了點 Bug (又忘記備份原始碼) 不過還是能正常使用啦！ 不過既然是使用 Ajax 技術來實踐，那麼跨域的問題真的就很惱人。 雖然 jQuery 有提供所謂的 JSONP 來實踐跨域。 不過我用 FireBug 看到那不斷增加的HTML我就頭昏（目前暫時使用 jQuery-JSONP Plugin ） 那麼，就小小說一下我的「心得」吧！ 我是參考官方的 Chat Room Deoms 原始碼來撰寫（縮減成練習的版本） 這種聊天室執行時，會消耗「記憶體」 不過就官方的程式運作來看，幾百筆資料似乎也才吃掉數MB(還是數千筆我忘了……) 聊天室整體的構造大致如下： 1. channel &#8230; <a href="http://blog.frost.tw/code/poston-2010-07-11/postid-583">Continue reading <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">JSApp.US – 免費的 Node.JS 伺服器</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>就我看來，用 Node.js 比 Ajax Push Engine 困難很多。<br />
不過，做出來的東西不論是自由度或者延展性，真的「好很多！」<br />
雖然目前自己寫的 Chat Room 出了點 Bug (又忘記備份原始碼)<br />
不過還是能正常使用啦！<br />
<span id="more-583"></span><br />
不過既然是使用 Ajax 技術來實踐，那麼跨域的問題真的就很惱人。<br />
雖然 jQuery 有提供所謂的 JSONP 來實踐跨域。<br />
不過我用 FireBug 看到那不斷增加的HTML我就頭昏（目前暫時使用 jQuery-JSONP Plugin ）</p>
<p>那麼，就小小說一下我的「心得」吧！<br />
我是參考官方的 Chat Room Deoms 原始碼來撰寫（縮減成練習的版本）</p>
<p>這種聊天室執行時，會消耗「記憶體」<br />
不過就官方的程式運作來看，幾百筆資料似乎也才吃掉數MB(還是數千筆我忘了……)</p>
<p>聊天室整體的構造大致如下：<br />
1. channel (應該說物件嗎？)<br />
2. sessions (Array )<br />
3.  methods (Array)</p>
<p>其中 channel 負責聊天訊息, sessions 負責紀錄進入聊天室的人，而 methods 則是我用來儲存HTTP請求回應的陣列……</p>
<p>channel 包含兩個函式，一個負責在 messages 陣列新增聊天紀錄，另一個則負責存取 messages 陣列。<br />
sessions 則儲存所有使用者的id, 並有 createSession() 函式負責加入新使用者。<br />
* sessions[id].destory() 是消除的函式（放在每個使用者的資料裡面）</p>
<p>而 methods 是一個陣列，並且對應一個 handler (官網好像是這樣稱呼)<br />
當 HTTP Server 接到請求，會判斷抓哪一個陣列出來使用。<br />
這樣大致上就完成架構了！</p>
<p>在撰寫過程中，幾乎沒有停下來。<br />
（大概是昨晚有簡單做一個收發的 test 所以才得力很多。）</p>
<p>最後中途是修正了幾次 Bug 才完成運行。<br />
* Node.js 發生程式錯誤會終止程式執行。</p>
<p>不過我很佩服官方的聊天室，好像運行一個多月都沒停止。<br />
（原始碼裡面明明有會卡死的部份，不過似乎不受影響）</p>
<p>晚點檢查完我的聊天室和跨域，就要進一步發展啦！<br />
（製作特製的 lib 來寫 Web Game~）</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">談起 APE 和 node.js</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">JSApp.US – 免費的 Node.JS 伺服器</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/code/poston-2010-07-11/postid-583/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>談起 APE 和 node.js</title>
		<link>http://blog.frost.tw/life/poston-2010-07-10/postid-582</link>
		<comments>http://blog.frost.tw/life/poston-2010-07-10/postid-582#comments</comments>
		<pubDate>Sat, 10 Jul 2010 11:15:09 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[生活雜記]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=582</guid>
		<description><![CDATA[說到我學習使用 Comet 技術，不外乎就是開發 Web Game 了！ 不過，在今天進行 Ajax Push Engine 的撰寫過程中，我發現了問題！ Ajax Push Engine 本身是一個 Server, 在其上的JavaScript(Server Side)都只是個 Module 而已！ 就因為這點，我改為向 node.js 發展。 （最近有網友反應網誌內容閱讀難度提高，所以今天我盡量簡單說明……） 要比喻 Ajax Push Engine 和 Node.js 的差異，大概可以用下面的方法形容。 APE 是一個完整的程式，其 Server Side只不過是個「擴充套件」 而 Node.js 則是一種程式語言，其Server Side就是完整的程式。 如此比較，就會發現 &#8230; <a href="http://blog.frost.tw/life/poston-2010-07-10/postid-582">Continue reading <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">JSApp.US – 免費的 Node.JS 伺服器</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>說到我學習使用 Comet 技術，不外乎就是開發 Web Game 了！<br />
不過，在今天進行 Ajax Push Engine 的撰寫過程中，我發現了問題！<br />
Ajax Push Engine 本身是一個 Server, 在其上的JavaScript(Server Side)都只是個 Module 而已！<br />
就因為這點，我改為向 node.js 發展。<br />
（最近有網友反應網誌內容閱讀難度提高，所以今天我盡量簡單說明……）<br />
<span id="more-582"></span><br />
要比喻 Ajax Push Engine 和 Node.js 的差異，大概可以用下面的方法形容。<br />
APE 是一個完整的程式，其 Server Side只不過是個「擴充套件」<br />
而 Node.js 則是一種程式語言，其Server Side就是完整的程式。</p>
<p>如此比較，就會發現 Node.js 不會受限於原本的限制。<br />
（好玩的是，使用APE時會用到他的JSF框架，就如同開發者被框住一樣！）<br />
#所謂的限制，其實就是 APE 無法開發多個程式，而 Node.js 可以。</p>
<p>目前某弦正在閱讀 Node.js 的 API 文件（可以說是開發文檔，或者函式/事件手冊吧！）<br />
也許哪天我寫出個心得，就會來做個簡單的教學！</p>
<p>就我所看到的網路教學中，建立一個HTTP伺服器最為簡單。<br />
（其實 Comet 技術本身就是 Ajax 的運用，和HTTP關係很大～）<br />
在加上 Node.js 本身內建 HTTP 伺服器/客戶端功能，所以建立「超容易！」</p>
<p>有興趣的朋友可以用 coLinux 在 Windows 下建立環境，然後安裝來測試。<br />
node xxx.js 是運行指令，想停止可以用 Ctrl+C 停止～</p>
<p>呼呼～<br />
繼續把閱讀到一半的文件看完～</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-10-30%2Fpostid-800&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 的 Comet Chat</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2010-07-11%2Fpostid-583&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用 Node.js 寫聊天室的心得～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-12%2Fpostid-585&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Node.js 上的 MySQL</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2011-03-07%2Fpostid-1141&from=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-10%2Fpostid-582">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">JSApp.US – 免費的 Node.JS 伺服器</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/life/poston-2010-07-10/postid-582/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

