6分鐘node.JS就上手
• Source code
– https://github.com/ericpi/ksdg-chat

• DEMO url
– http://www.toofatcake.com:8080/

• ericpi
...
Node.JS 最有名的範例
只能回 hello world 的 httpd 能幹
嘛..
100行的 chatroom server
• Source code
– https://github.com/ericpi/ksdg-chat

• DEMO url
– http://www.toofatcake.com:8080/
APIs
• /join
– 註冊加入chatroom, JSON response & set-cookie

• /stream
– Long polling 接口, HTML p tag response

• /send
– 送出訊息,...
server

browser
GET /
client.html
POST /join
/join response

GET /stream

user
interaction

client
js process

POST /send
...
Client code (105 lines)

Server code (101 lines)
未完成
• API error handling
• Exclusive Problem

• Message Queue & Log
• Javascript style & flow control

• Node.JS modulize
...
Thanks
KSDG LT: 6分鐘node.JS就上手
Upcoming SlideShare
Loading in …5
×

KSDG LT: 6分鐘node.JS就上手

921 views

Published on

Source code
https://github.com/ericpi/ksdg-chat

快快樂樂用~100行code寫出小型聊天室

Published in: Technology, Design
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
921
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
8
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

KSDG LT: 6分鐘node.JS就上手

  1. 1. 6分鐘node.JS就上手 • Source code – https://github.com/ericpi/ksdg-chat • DEMO url – http://www.toofatcake.com:8080/ • ericpi • KKBOX S.RDC
  2. 2. Node.JS 最有名的範例
  3. 3. 只能回 hello world 的 httpd 能幹 嘛..
  4. 4. 100行的 chatroom server • Source code – https://github.com/ericpi/ksdg-chat • DEMO url – http://www.toofatcake.com:8080/
  5. 5. APIs • /join – 註冊加入chatroom, JSON response & set-cookie • /stream – Long polling 接口, HTML p tag response • /send – 送出訊息, JSON response • / – 客戶端介面, html & javascript code for Browser (client.html)
  6. 6. server browser GET / client.html POST /join /join response GET /stream user interaction client js process POST /send wait for event /send response /stream response GET /stream ………... client js process
  7. 7. Client code (105 lines) Server code (101 lines)
  8. 8. 未完成 • API error handling • Exclusive Problem • Message Queue & Log • Javascript style & flow control • Node.JS modulize • More…
  9. 9. Thanks

×