msndevs / msnp-sharp

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

Get contacts/conversation from TextMessageReceived #263

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I did upgrade to a new MSNPSharp version and a lot of my code needed to be 
adjusted. That mostly wasn't the problem. But there is one thing I can not 
figure out.
I want to get all contacts of one conversation in the OnTextMessageReceived 
event.
Previously I just used e.Contacts() but now this isn't available anymore.
I tried getting the conversation first using something like
Messenger.MessageManager.GetConversation(Messenger.MessageManager.GetID(e.Sender
))
but it only works with the initiator of the conversation and not the other 
contacts (returns Nothing).
So any suggestions on what to do?

What version of the product are you using? (MSNPSharp, OS, Mono etc.)
MSNPSharp 313, Windows 7 x64, .NET 2.0, VS 2005
Is your code check out from SVN or download from our download site?
download site

Original issue reported on code.google.com by matti_ko...@msn.com on 11 Apr 2011 at 1:49

GoogleCodeExporter commented 9 years ago
Switchboard conversation is deprecated so you don't need GetID anymore. Just 
call:

e.Sender.SendMessage(TextMessage);

What happens if you call this method?
Now everybody is contact. Contact is contact, Conversation(TemporaryGroup) is 
contact, Circle is contact. If e.Sender.ClientType == IMAddressInfoType.Circle 
|| IMAddressInfoType.TemporaryGroup, all participants will receive the message 
you sent by calling e.Sender.SendMessage(TextMessage);

If you really need participants you can do some checks:

ContactList parties = null;

if (e.Sender.ClientType == IMAddressInfoType.TemporaryGroup || 
e.Sender.ClientType == IMAddressInfoType.Circle)
{
    parties = e.Sender.ContactList; // Participants
    Contact originalSenderToChat1On1 = e.Sender.OriginalSender;
}

For more information, please see change log:
http://code.google.com/p/msnp-sharp/wiki/MSNPSharp_v4X

Original comment by hepha...@gmail.com on 11 Apr 2011 at 7:37

GoogleCodeExporter commented 9 years ago
Thank you for your reply. Unfortunately IMAddressInfoType does not seem to be 
recognized (not declared) and I am unable to locate it in teh object browser as 
well.
Also e.Sender.ClientType seems to always be Object.PassportMember.

It may be a good thing to simplify all of that into "contact" but I need more 
information for my program.

I need to store specific variables per-conversation (as one user may chat with 
my program in more then one session and with various other participants and 
every conversation needs to have individual variables).
I previously used a conversation-ID to separate them and align my variables to. 
And from that ID I could also get all participants of that conversation.

Is there a way to get said ID from the TextMessageReceived event?

Original comment by matti_ko...@msn.com on 11 Apr 2011 at 8:02

GoogleCodeExporter commented 9 years ago
Download latest version 4.0.RC or checkout svn and recompile your code. 
IMAddressInfoType in MSNPSharp namespace.

Again you can't GetID anymore because MSNP21 doesn't support it.

If you really need participants you can do some checks:

ContactList parties = null;

if (e.Sender.ClientType == IMAddressInfoType.TemporaryGroup || 
e.Sender.ClientType == IMAddressInfoType.Circle)
{
    parties = e.Sender.ContactList; // Participants
    Contact originalSenderToChat1On1 = e.Sender.OriginalSender;
}

For more information, please see change log:
http://code.google.com/p/msnp-sharp/wiki/MSNPSharp_v4X

Original comment by hepha...@gmail.com on 11 Apr 2011 at 8:15

GoogleCodeExporter commented 9 years ago
Okay thank you
I will need to redo my code again for the new version. I will try to find a 
solution with that. Thanks.

Original comment by matti_ko...@msn.com on 11 Apr 2011 at 9:03

GoogleCodeExporter commented 9 years ago
Hello Matti,

Since the introduction of MSNP21, a lot of things have to be changed (although 
we try hard to maintain a certain degree of backward compatibility, it still 
breaks a lot of old things), we are really sorry for the inconvenience.

Original comment by freezing...@gmail.com on 11 Apr 2011 at 8:40

GoogleCodeExporter commented 9 years ago
Thank you for your support.
I managed to re-write and adjust my code work in the new version.
I am very satisfied with the results.
The new version of the API is (after the porting problems are sorted out) much 
more user-friendly and error-redundant then the previous one.

For everyone interested, I used the e.Sender.Account -fake/temp-account as a 
unique ID to identify and separate my conversation.

Thank you for your help and keep up the good work! :)

Original comment by matti_ko...@msn.com on 12 Apr 2011 at 11:51

GoogleCodeExporter commented 9 years ago
You are welcome, could you please tell us what project you are working on if 
you don't mind sharing your project on our user's list?

Original comment by freezing...@gmail.com on 13 Apr 2011 at 12:22