|
   |
|
|
xssinterface and Google Gears
I mentioned the cross domain library, xssinterface, created by Malte Ubl on Ajaxian the other day. His library abstracts on top of postMessage() and browser hacks to give you cross domain work. No sooner than I say “It would be nice if the library used cross domain workers if Gears is installed.” than Melde comments “Thanks for the hint to google gears. It is now implemented in trunk :)”. How about that for service! Below is his first version that uses cross domain workerpools and the database to keep a message queue going. Very nice! var wp = google.gears.workerPool; wp.allowCrossOrigin(); wp.onmessage = function(a, b, message) { var origin = new String(message.origin); var parts = origin.split("/"); var domain = parts[2]; parts = domain.split(":"); // remove port domain = parts[0]; var recipient = domain; var channelId = message.text; var db = google.gears.factory.create('beta.database'); db.open('database-xssinterface'); db.execute('create table if not exists XSSMessageQueue' + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, recipient_domain TEXT, channel_id TEXT, message TEXT, insert_time INTEGER)'); // delete (and thus ignore) old messages var maxAge = new Date().getTime() - 2000; db.execute('delete from XSSMessageQueue where insert_time < ?',[maxAge]); // find new messages for me var rs = db.execute('select id, message from XSSMessageQueue where recipient_domain = ? and channel_id = ?', [recipient, channelId]); // there is a new message for the recipient if (rs.isValidRow()) { var id = rs.field(0); var text = rs.field(1); db.execute("DELETE from XSSMessageQueue where id=?", [id]); // unqueue message wp.sendMessage(text, message.sender) } rs.close(); }
|
|
 |
|
No reactions yet.
Please login or sign up to rate this intel.
Please login or sign up to add a comment.
The copyright for this content entitled "xssinterface and Google Gears" has been specified by the contributor as:
All Rights Reserved
This content may not be copied, distributed or adapted by anyone under any circumstances.
|
 |
May, 2012
2008
January, February, March, April, May, June, July, August, September, October, November, December
2009
January, February, March, April, May, June, July, August, September, October, November, December
2010
January, February, March, April, May, June, July, August, September, October, November, December
2011
January, February, March, April, May, June, July, August, September, October, November, December
2012
January, February, March, April, May
|
|
Not a member yet?
Qondio is a powerful network for making it online. If you have a website to
promote, we can help.
Sign up and get in on the action.
|
|
Welcome to Qondio! Discover the awesome power this network can deliver by going to our About page. Or you could skip straight to the Sign Up form.
|
|