Geo chat
-
Upload
wearefractal -
Category
Technology
-
view
3.146 -
download
4
description
Transcript of Geo chat
![Page 1: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/1.jpg)
Aaron Murray & Eric Schoffstall@WeAreFractal
Building a GeoChat mobile app and the birth of a web framework
![Page 2: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/2.jpg)
What are we building?
Chattr is a mobile chat app that lets you open up a chatroom based on your geographic location
What are our technical requirements?
• Node.js • Websockets• Native Mobile App for iOS, Android• Coffescript friendly
![Page 3: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/3.jpg)
What do we need?
• Native Mobile Bridge– Titanium, Phonegap
• Mobile Web Framework – JQuery Mobile, Titanium, Sencha Touch, Dojo Mobile, Zepto.js
• Communication– Socket.io, Now.js
• Database– MongoDB, CouchDB, Redis
• ORM – Mongoose
• Application Framework– Express, SocketStream
![Page 4: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/4.jpg)
Native Mobile Bridge
• Compile JS + HTML + CSS + Titanium APIs to native code• Native UI• Use your web skills to build
Titanium Mobile (http://www.appcelerator.com/products/)
![Page 5: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/5.jpg)
Native Mobile Bridge
Titanium Mobile (http://www.appcelerator.com/products/)
![Page 6: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/6.jpg)
Native Mobile Bridge
• ACTUALLY native web technologies • Wrapped in a webkit renderer• Bridged to iOS and android • Have to run vanilla eclipse (not aptana)• Android emulator is absurd – debug on your phone
http://www.phonegap.com/
![Page 7: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/7.jpg)
JQuery + Now.js PoChttps://github.com/wearefractal/Chattr-JQuery-PoC
![Page 8: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/8.jpg)
JQuery + Now.js PoChttps://github.com/wearefractal/Chattr-JQuery-PoC
var fs = require('fs');var server = require('http').createServer(function(req, response){ fs.readFile(__dirname+'/chattr.html', function(err, data){ response.writeHead(200, {'Content-Type':'text/html'}); response.write(data); response.end(); });});server.listen(8080);var nowjs = require("now");var everyone = nowjs.initialize(server);
everyone.on("connect", function(){ console.log("Joined: " + this.now.name);});
everyone.on("disconnect", function(){ console.log("Left: " + this.now.name);});
everyone.now.distributeMessage = function(message){ everyone.now.receiveMessage(this.now.name, message);};
![Page 9: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/9.jpg)
JQuery + Now.js PoChttps://github.com/wearefractal/Chattr-JQuery-PoC
Pros• Super easy + fast • Looks good
Cons• Was in alpha forever• Beta = alpha• Orientation on device rotate etc• Just not quite there
![Page 10: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/10.jpg)
Zepto + Now.js PoChttps://github.com/wearefractal/Chattr-Zepto-PoC
Pros• Super lightweight (~2k filesize)• JQuery-compatible syntax• Decent skin OOTB
Cons• Not mature enough
http://zeptojs.com/
![Page 11: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/11.jpg)
We went with Sencha Touch
Pros• Very mature• Good looking
Cons• Code• Licensing
http://www.sencha.com/products/touch/
![Page 12: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/12.jpg)
Now.jshttps://github.com/wearefractal/Chattr-JQuery-PoC https://github.com/wearefractal/Chattr-Zepto-PoC
Pros• Super easy to set up client -> server communication • Has baked-in grouping (pub-sub)
Cons• WTF is a magic pocket?• Almost 2k LoC – WTF??
http://nowjs.com
We went with
http://socket.io/
![Page 13: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/13.jpg)
Database
• Document-oriented DB• Dynamic Schemas, Auto-sharding, Map-reduce, Geo support• Best for storing structured data • Best drop-in replacement for MySQL or similar imo• http://www.mongodb.org/display/DOCS/Comparing+Mongo+DB+and+Couch+DB
http://www.mongodb.org/
http://mongoosejs.com/
• ORM-like module for node
![Page 14: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/14.jpg)
Database
• In-memory, persistent, journaled key-value store• Achieve persistent shared memory
Mongo vs Redis
2 different use cases for us –• Mongo for traditional persistence• Redis for pub-sub for chat
http://redis.io/
![Page 15: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/15.jpg)
Application Framework
Pros• Lots of traction, examples • 3rd party modules• Projects built on it • Website looks good?
Cons• Too much code!• Focus on routing, view rendering, etc do not need• Older-style paradigm imo
http://expressjs.com/
![Page 16: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/16.jpg)
Application Framework
Pros• Embraces Single Page Application (SPA) paradigm• websockets, no HTTP routing• Coffeescript friendly
Cons• Too many features / too much code!
https://github.com/socketstream/socketstream
![Page 17: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/17.jpg)
![Page 18: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/18.jpg)
![Page 19: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/19.jpg)
![Page 20: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/20.jpg)
• DDD-based – only artefacts: Models, Services, Commands, Views• o. = jquery-like convienence lib for both client and server• single entry-point for incoming data, all data is sanitized before it’s accesed by services • only models are passed from client to server, no loose vars• tuneable communication layer abuse levels • obfuscation
ModelRequest{ module: 'Chat', model: 'Chatroom', type: 'find', query: {
}, mid: 'SessionID'}
![Page 21: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/21.jpg)
Plugs• Commander – CLI microframework for node.js• Orchid web framework• Kyuzo
![Page 22: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/22.jpg)
![Page 23: Geo chat](https://reader037.fdocuments.in/reader037/viewer/2022102922/549a4a56ac7959092e8b5b43/html5/thumbnails/23.jpg)
Demo / QA