What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Solved] XMLHTTP post

[Solved] XMLHTTP post
Author: Message:
Deco
Full Member
***


Posts: 188
Reputation: 4
41 / Male / Flag
Joined: Aug 2006
O.P. RE: XMLHTTP post
code:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var LastStatus = "offline";
var FirstTime = true;
var SignOut = false;
xmlhttp.onreadystatechange = function() {
    Debug.trace("xmlttp function");
    if(xmlhttp.readyState==4) {
        if(xmlhttp.status == 200){
            Debug.Trace("Received info-> " + xmlhttp.responseText);
            ParseResponse(xmlhttp.responseText);
        }else{
            Debug.trace("Post failed!");
        }
    }
}

function OnEvent_SignIn(email) {
PostInfo('online');
MsgPlus.AddTimer("verificar",120000);
}
function OnEvent_SignOut(email) {
SignOut = true;
PostInfo('offline');
}
function PostInfo(status) {
Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', "http://www.mysite.com/statusmsn.php");
xmlhttp.open("POST", "http://www.mysite.com/statusmsn.php", true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var str = "user=" + Messenger.MyEmail + "&status=" + status;
Debug.trace("Posted info-> " + str);
xmlhttp.send(str);   
}

function ParseResponse(strText) {
    Debug.trace("Parsing...");
    if (!SignOut) {
    var index = strText.indexOf(" ");
    if (index > 0) {
        strName = strText.substr(0,index);
        strStatus = strText.substr(index+1);
        Debug.trace("Parse-> " + strName + " " + strStatus);
        if(strName == "heremail@hotmail.com") {
            if (strStatus == "online") {
                if (LastStatus == "offline" || FirstTime) {
                    MsgPlus.DisplayToast("Toast", "girlfriend está online!\nClique aqui para abrir um chat.", "","OnMyToastClick", strName);
                    FirstTime = false;
                    LastStatus = "online";
                }
            } else {
                if (LastStatus == "online"|| FirstTime ) {
                    MsgPlus.DisplayToast("Toast", "Deco's girlfriend está offline...", "","");
                    LastStatus = "offline";
                }
            }
        } else {
            if (strStatus == "online") {
                if(LastStatus == "offline"|| FirstTime) {
                MsgPlus.DisplayToast("toast", "Deco está online!\nClique aqui para abrir um chat.", "","OnMyToastClick",strName);
                FirstTime = false;
                LastStatus = "online";
                }
            } else {
                if (LastStatus == "online"|| FirstTime) {
                    MsgPlus.DisplayToast("Toast", "Deco está offline...", "","");
                    LastStatus = "offline";
                }
            }
        }
    }
    } else {
    Debug.trace("Singing out.");
    }
}

function OnMyToastClick(Param)
{
    var tmpContact = Messenger.MyContacts.GetContact(Param);
    Messenger.OpenChat(Param);
}

function OnEvent_Timer(tID) {
    if (tID == "verificar") {
        PostInfo('online');
        Debug.trace("Checando informação.");
        MsgPlus.AddTimer("verificar",120000)
    }
}


Updates the info in the server just right. Problem is that when the timer comes in and it posts an update.. it won't activate the .onreadystatechange function. Why?

Thanks for all the people that helped me in this thread and by PMs.

[Image: signature-user=31&back=4&clr=106,141,166&size=100.png]
08-29-2007 03:08 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Solved] XMLHTTP post - by Deco on 08-28-2007 at 09:12 PM
RE: XMLHTTP post - by roflmao456 on 08-29-2007 at 12:20 AM
RE: RE: XMLHTTP post - by davidpolitis on 08-29-2007 at 10:15 AM
RE: XMLHTTP post - by Deco on 08-29-2007 at 01:16 AM
RE: XMLHTTP post - by -dt- on 08-29-2007 at 01:54 AM
RE: XMLHTTP post - by Deco on 08-29-2007 at 03:08 PM
RE: XMLHTTP post - by matty on 08-29-2007 at 03:39 PM
RE: XMLHTTP post - by Deco on 08-29-2007 at 04:16 PM
RE: XMLHTTP post - by Matti on 08-29-2007 at 04:38 PM
RE: XMLHTTP post - by Deco on 08-29-2007 at 04:43 PM
RE: [Solved] XMLHTTP post - by roflmao456 on 08-29-2007 at 05:33 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On