1 / 7

Chat Room App

Chat Room App. Logan Linn Network Application Design Fall 2010. Overview. Connects to server running a simple Node.js chat room application Initially browser-based chat Server responds in JSON My app connects just as the browser-based client does Messages sent and received in real-time.

glenys
Download Presentation

Chat Room App

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chat Room App Logan Linn Network Application Design Fall 2010

  2. Overview • Connects to server running a simple Node.js chat room application • Initially browser-based chat • Server responds in JSON • My app connects just as the browser-based client does • Messages sent and received in real-time JSON Notation {key : value} [element0, element1, element2] [{id: 4, name:“foo”},{id:2,name:“bar”}]

  3. Wtf is Node.js? • “Evented I/O framework” • Uses V8 JavaScript engine • Developed by Google • Ships w/ Chrome • Executed server side • Driven by async. events • Everything is non-blocking • Handles concurrent connections using a fraction of the memory thread-based • Highly scalable “Node tells the operating system (through epoll, kqueue, /dev/poll, or select) that it should be notified when a new connection is made, and then it goes to sleep. If someone new connects, then it executes the callback. Each connection is only a small heap allocation”

  4. Node.js Hello World var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(8080); console.log('Server running at http://127.0.0.1:8080/');

  5. Back to the App: the Join Activity • User sets nickname, chooses server • App sends GET request to join using nickname • If nickname is already in use, user is asked to change nickname • Otherwise, Chat activity is launched

  6. Chat Activity: Long Polling • GET request for messages • App sends time of last msg • If no new messages since last msg, server “drags out” the response • New messages cause the server to write & end the response. • If no new messages after ~30s, server writes & ends response. • Chat Log uses ListView, ArrayAdapterw/ JSONObjects • ListView scrolls w/ chat using transcript mode

  7. Demo / Questions? www.loganlinn.com

More Related