kythyria / msnp-sharp

Automatically exported from code.google.com/p/msnp-sharp
0 stars 0 forks source link

Cant send messages if receiver leaves convo open too long after inactivity. #173

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I am making a bot to send messages to myself (alerts) for when certain
things happen online .. so I get notifications right away.

Once the bot starts, it creates a conversation and invites me... after that
it never closes it unless IsSessionEstablished is false... then it closes
and restarts the convo.

Whats happening is.. if I leave the convo open too long after no messages
for along time.. then when the bot tries to message me.. I dont get the
messages.  The bot receives no errors and IsSessionEstablished is true...
as far as the bot knows the message was sent.

If I close the window.. then the bot can message me again.

I am using MSNPSharp 2.5.8.1372.. MSNP15

Here is the code I use.. very basic.. I am probably stupid and missing
something tho lol

 public void sendMsg(string msg)
        {

                Contact selectedContact =
messenger.ContactList.GetContact("myemail");

                if (selectedContact.Online == true)
                {

                        if (!convos.Switchboard.IsSessionEstablished)
                        {
                            Console.WriteLine("RESTARTING CONVO");
                            convos.Switchboard.Close(); 
                            convos = messenger.CreateConversation();
                            convos.Invite(selectedContact);
                            addresses = toAddress;

                        }

                    if (convos.SwitchboardProcessor.Connected == false)
                    {

convos.Messenger.Nameserver.RequestSwitchboard(Conversation.Switchboard, this);
                    }

                    convos.Switchboard.SendTextMessage(message);

                }
}

Any help is greatly appreciated!

Thanks

Original issue reported on code.google.com by ccbai...@gmail.com on 24 Dec 2009 at 5:52

GoogleCodeExporter commented 9 years ago
Id like to add.. that the reason I leave the convo switchboard open all the 
time ..
instead of closing it.. is because sometimes the bot needs to send me a bunch of
messages at once.. and if it closes then opens it repeatedly it gets 
disconnected
from the MSN servers.

Also, its possible that I am mistaken about it not working because i leave the 
window
open too long.. it could be something else.. it just seemed like it was that.

Original comment by ccbai...@gmail.com on 24 Dec 2009 at 6:00

GoogleCodeExporter commented 9 years ago
I think maybe I am trying to send the meessages too fast after the convo is 
created?

How long should I wait?  in the example it doesnt seem to wait.. but I could be
mistaken..

also how long does it take until the session is closed by itself?

Original comment by ccbai...@gmail.com on 24 Dec 2009 at 7:11

GoogleCodeExporter commented 9 years ago
Hmm... I get this too, when I leave one conversation quite inactive for quite 
some time 
(let's say 20 minutes at least), I cannot respond further than that, either I 
can't 
send messages which don't get to the other user, and that I can't see what the 
other 
contact is sending (messages).

I'll see about it soon enough if I get time. That's a good report you have 
there too.

Original comment by electk...@gmail.com on 25 Dec 2009 at 2:56

GoogleCodeExporter commented 9 years ago
Hi,
This is not a bug, the session will be closed after a period of time if you do 
not 
send anything. If you want to keep the session alive, you need to set the 
AutoKeepAlive property to true for each conversation instance.

Original comment by freezing...@gmail.com on 26 Dec 2009 at 4:02