Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional XMPP Programming with JavaScript and jQuery
This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 1st, 2012, 05:48 PM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default send message on page un load

Hi Metajack,


I'm trying to send an message to all users on the onbeforeunload event for the window. So If a user navigates away or closes the browser tab, other will get that message. Below are my codes but it is not working


window.onbeforeunload = function(){ myUnloadEvent(); }
function myUnloadEvent() {
var ownjid = $('#hid_jid').val();
var curruname = ownjid.split("@");
var ownername = curruname[0].toUpperCase();

var yourid = $('#yourID').val();

var timeNow = new Date();
var hours = timeNow.getHours();
var minutes = timeNow.getMinutes();
var seconds = timeNow.getSeconds();
var timeString = "" + ((hours > 12) ? hours - 12 : hours);
timeString += ((minutes < 10) ? ":0" : ":") + minutes;




var allpubval = $('#pubroomval').val();
var text = 'save';
allpubval = allpubval.split('##');
var ulength = allpubval.length;
for(var i=0;i<ulength;i++){
var sendjid = allpubval[i];
Arthur.connection.sync = true;
var msg = $msg({to: sendjid, type: 'chat',stamp: timeString, pname: ownername,pid: yourid,modetype: 'public'}).c('body').t(text);
Arthur.connection.sync = true;
Arthur.connection.send(msg);
Arthur.connection.flush();
}


}
  #2 (permalink)  
Old December 2nd, 2012, 01:18 AM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

I don't have much experience with onbeforeunload, but this patch may help:
https://github.com/metajack/strophejs/issues/16

The problem is that XHR is asynchronous, so the requests don't finish before the page is destroyed.
  #3 (permalink)  
Old December 2nd, 2012, 03:17 AM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Metajack,

I could not able to see this patch in the core.js which is in the github. But I added the below thing in my strophe.js and found that it is still incorrect.

//req.xhr.open("POST", this.service, true); //commented this line
var async = !('sync' in this && this.sync === true);//added this line
req.xhr.open("POST", this.service, async);

Please tell me If I am wrong and also help to how I can add this functionality.

Thanks
  #4 (permalink)  
Old December 3rd, 2012, 03:09 PM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Metajack,

Please let me know to my above written points.

Thanks
  #5 (permalink)  
Old December 5th, 2012, 11:28 AM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Metajack,

Please take a look at this post and let me know how I can send a stanza before browser close. I have applied the above patch but it is not working.

Thanks
  #6 (permalink)  
Old January 19th, 2013, 05:39 PM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Metajack,

I need your urgent help in this , please guide me here.

Thanks
  #7 (permalink)  
Old January 19th, 2013, 11:12 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

Sorry, I'm not sure what I can do to help. I don't have any experience with this issue directly, and I don't have the time to go dig into myself.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send Message to Email inbaa ASP.NET 1.0 and 1.1 Professional 2 August 28th, 2006 05:45 AM
send message to many recipients eda BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 May 29th, 2006 08:49 PM
Send a Message box to another machine red4vbs VBScript 3 January 31st, 2005 04:33 PM
How to send message to SMS !!!!! stevenThu Classic ASP Professional 4 August 26th, 2004 10:25 AM



All times are GMT -4. The time now is 09:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.