What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » OnEvent_ContactSignIn triggered twice...?

OnEvent_ContactSignIn triggered twice...?
Author: Message:
DeBiese
New Member
*


Posts: 4
42 / Male / –
Joined: Aug 2006
O.P. Roll Eyes  OnEvent_ContactSignIn triggered twice...?
I created a script that is capable of "automatically" sending messages to contacts in my list. You can create messages to be sent for any event of the contact (signin, change nick, change pm, change media, change status, messagereceived) and you can link this message on a number of statusses for yourself to be in.

So if you set it to SignIn of a contact when you are Away, it won't be sent when your status is online.

Coming to "the problem":

The OnEvent_ContactSignIn seems to be triggered twice when a contact signs in (code is executed twice...). When the message is sent, in one of the two cases it is sent to the contact that sings in as a message that he received when he was offline.

Anybody an idea on how to solve this "problem"?

Many thnx!
08-25-2006 03:41 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: OnEvent_ContactSignIn triggered twice...?
Have you used Debug.Trace() to see if it's really being called twice?
[Image: spartaafk.png]
08-25-2006 04:09 PM
Profile PM Web Find Quote Report
DeBiese
New Member
*


Posts: 4
42 / Male / –
Joined: Aug 2006
O.P. RE: OnEvent_ContactSignIn triggered twice...?
Yes, i looked in the debug window. First thing to look at right...
The event is executed twice...

First time the message is sent as if the contact is online, second time the message is sent as being a message the contact received while being offline...

I'm gonna get ahead of you: no, it is not a message the contact got while being offline. (I set up another mail account just for testing this...)
08-25-2006 06:15 PM
Profile PM Find Quote Report
Deco
Full Member
***


Posts: 188
Reputation: 4
42 / Male / Flag
Joined: Aug 2006
RE: OnEvent_ContactSignIn triggered twice...?
As Jerry Maguire would say it: "SHOW Me the... code!" and maybe we can help :)

Thanks
08-25-2006 06:30 PM
Profile E-Mail PM Web Find Quote Report
DeBiese
New Member
*


Posts: 4
42 / Male / –
Joined: Aug 2006
O.P. RE: OnEvent_ContactSignIn triggered twice...?
code:
function sendMessageWhenRequired(myMessage, Email)
{
    if (myMessage.length > 0)
    {
        //Check if my status requires sending a message
        var myStatus = Messenger.MyStatus;
        var sendStatus = myMessage[3].split(";");
        for (var i=0; i<sendStatus.length; i++)
        {
            var eSendStatus = getStatusEnum(sendStatus[ i]);
            if (eSendStatus == myStatus)
            {
                //Don't send when status of the contact is offline or appears offline or status is unknown
                var contactStatus = Messenger.MyContacts.GetContact(Email).Status;
                if (contactStatus != 1 && contactStatus != 2 && contactStatus != 0)
                {
                    //Send a message
                    var chWnd = Messenger.OpenChat(Email);
                    if (chWnd != null) chWnd.SendMessage(myMessage[2]);
                    break;
                }   
            }
        }       
    }
}

function OnEvent_ContactSignin(Email)
{
    //Get a message for signin event for this email if it exists
    var myMessage = GetMessage(Email, "SignIn");
    sendMessageWhenRequired(myMessage, Email);
}


A little explanation maybe:

code:
var myMessage = GetMessage(Email, "Signin");
GetMessage is a function in another js file wich looks in an xml file for a node with the attributes 'email' and 'signin'. If it is found an array of length 4 is returned. This array contains: the email of the contact, on which action a message is to be send, the message to send and all statusses in which a message should be automatically sent. The last value in the array is build as following: Online;Away;Busy, hence the split you see in sendMessageWhenRequired.

The function sendMessageWhenRequired is also called for all the other message that are sent and they only get delivered once.

As I also said before, the OnEvent_ContactSignin - event is executed twice ...

Try it... Make yourself a dummy account, or ask a friend to signout and in again so that you can send a message...

There just has to be a reason why that event is executed twice...

This post was edited on 08-25-2006 at 09:04 PM by DeBiese.
08-25-2006 09:02 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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