More Related Content
Similar to Nodejs Introduction (20)
Nodejs Introduction
- 26. Node.js --
• CPUにもの凄い負荷のかかる処理(CPU Heavy)は苦手
• マルチコア環境を使いこなせない
これは将来 Worker を使って解決の予定
• 処理してない例外が発生するとイベントループ全体が止ま
る
uncaughtException という機構がある。
• コールバック入れ子の嵐
Defferd とか使う
• Windows.. orz
つ VM
2010年11月21日日曜日
- 30. ECMA 5th edition
基本は 3rd で、全部ではないが 5th も使える。
• getter/setter Syntax
• Property Descriptor
• Native JSON Object
• Array.prototype.(map¦reduce¦filter)
etc
2010年11月21日日曜日
- 34. Node.js を始めるには
言語 環境管理 パッケージ管理
Ruby rvm gem
Python Virtualenv PyPI
Perl Perlbrew CPAN
node nave npm
2010年11月21日日曜日
- 35. Node.js で "HelloThe World!!"
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('The World!!n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
2010年11月21日日曜日
- 37. Socket.io
WebSocketが無かったら
(フォールバック)
• Adobe Flash Socket
• ActiveX HTMLFile (IE)
• XHR with multipart encoding
• XHR with long-polling
• JSONP polling (for cross-
domain)
サポートするブラウザ
• Safari 4
• Google Chrome 5
• Internet Explorer 6
• Internet Explorer 7
• Internet Explorer 8
• iPhone Safari
• iPad Safari
• Firefox 3
• Firefox 4 (Minefield)
• Opera 10.61
2010年11月21日日曜日
- 38. Socket.io サーバ側
var socketio = require('socket.io');
var io = socketio.listen(server);
io.on('connection', function(client) { //接続イベント
client.on('message', function(message) { //受信イベント
//クライアントがメッセージを送って来たら実行される。
//messageが送られて来たデータ
client.send(message); //送って来た本人だけに送る。
client.broadcast(message); //送って来た人以外全員に送る。
});
});
2010年11月21日日曜日
- 39. Socket.io クライアント側
$(function() {
var socket = new io.Socket(null, {port: 8080});
socket.connect();
$('#button').click(function() { // 送信
socket.send('message');
return false;
});
socket.on('message', function(obj) { // 受信ベント
$('#output').text(obj);
});
});
2010年11月21日日曜日
- 40. 他のモジュール
•FW
Express (like Sinatra), etc
•Template
ejs(like erb), haml, sass, Jade, etc
•RDB
sqlite, mysql, postgresql, etc
•KVS
couch, mongodb, redis, etc
•Test/Spec
Vows, jasmine, Qunit, etc
2010年11月21日日曜日
- 42. 日本語リソース
JP User Group : http://nodejs.jp/
@yssk22 hands on : http://bit.ly/a7Mm5i
@meso hands on : http://bit.ly/bNSDyD
@bad_at_math :
node.js とは何か : http://bit.ly/bdfrbz
2010年11月21日日曜日
- 43. 他参考資料
• 本家: http://nodejs.org/
• JSConf09 Slide: http://bit.ly/6lZvhy
• JSConf10 Slide: http://bit.ly/c67UQB
• Knockout: http://nodeknockout.com/
• Bench: http://bit.ly/ao3zc5
• C10K: http://bit.ly/N2DWS
2010年11月21日日曜日