QUOTE(Dr.O @ Fri Mar 23 2007, 15:42) [snapback]375677[/snapback]
Great, thx a lot !!!
There is a little problem now I have not solved yet:
chat.SendMessage("test") sometimes writes 2 or more times "test" into the chat.
I have no loops, so I cannot understand why it writes more than one time...
In the real Skype Chat? or You see message status more than once?
You will receive a status for every message sent or received in a multi-chat to each user in the chat. These status messages can be:
https://developer.skype.com/Docs/Skype4COML...atMessageStatusSo you need to do something like this on a sent message, if you want to process only the first status received on a sent chat message:
CODE
if (LastSent == ichatmessage.Id.ToString())
{
return;
}
LastSent = ichatmessage.Id.ToString();
Your code here........
I am sure that if you are sending a message more than once into the real Skype chat, that if you set a breakpoint, you will see you are in fact sending twice, maybe because you are not dealing with the multiple status messages you may be receiving for a single sent chat message into a Skype multi-chat properly, because you did not realize that you will get a status message from each Skype user in a multi-chat vs always one status when using a private chat.
Each message is assigned an ID #, so, you can tell if you have seen a status for a specific message already or not, on a chat by chat basis.
Example: If you have 4 people including you in a Skype multi-chat you can receive a sending and sent status for each Skype user in the multi-chat, the status will include the same message ID but there will be one for each person in the multi-chat. This allows you to determine who has or has not received the message yet on a per user basis. The same applies for a received and read status as well.
So for each sent message sent into a Skype multi-chat you will receive a status message for each of these on a message you sent into a multi-chat:
1. Sending ("To the Skype Cloud")
2. Sent ("Received by the Skype Cloud")
3. Received (Received by the specific Skype User")
4. Read ("The Skype user could receive a notification and not have opened the chat yet, once they do, you see this status")
Please remember, you will see these status messages from each and every user in the chat, which means, some may receive your sent message hours or days later, if they were logged off when you sent the message into the multi-chat.
These all will have the same message ID but will be from each Skype user in the multi-chat.
CODE
private void Skype_MessageStatus(IChatMessage ichatmessage, TChatMessageStatus Status)
{
if (Status == TChatMessageStatus.cmsRead)
{
return;
}
if (LastSent == ichatmessage.Id.ToString())
{
return;
}
try
{
if ((ichatmessage.Type == TChatMessageType.cmeSaid) && (ichatmessage.Chat.Name == MyChatName))
{
switch (ichatmessage.Status)
{
case TChatMessageStatus.cmsSent:
Your Code here.....
case TChatMessageStatus.cmsReceived:
Your Code here......
}
LastSent = ichatmessage.Id.ToString();
{
}
This allows you to avoid read status messages because they could come hours, even days later for any user in the multi-chat. It also allows you to process only the first sent message response, and to avoid sending, and receiving status messages being processed, as well. I left the default out in tha case statement but you get the idea.
TChatMessageType.cmeSaid confines the status messages to text messages sent and received so you don't look at people leaving the chat and joining the chat as well as other status messages that don't contain chat text. The code format on the board sucks, but I did my best to line things up to give you a basic idea of how to NOT process messages other that chat text sent/received and only process one text message sent/received for the entire multi-chat.
There is one downside to using this method, if everyone in this chat is offline for example, you will never receive a received status for example until on Skype user in the multi-chat comes online. But if you don't isolate what messages you want to process, you will be swamped. This isolates you to one copy of any sent/received message in a multi-chat. If you are going to support multiple multi-chats in progress at anytime, you would want to keep a LastSent for each one.
The reason why you return at the top of the message event handler for TChatMessageStatus.cmsRead is because if your program/Skype client was offline for days, and before you went offline you sent many chat messages that were not read before you went offline, you can cause an abend in your program, because you could get swamped with read status messages from days ago. Since you were offline, you would never receive the received status, but you would receive a read status for any message you sent before you went offline and all at once, as soon as your Skype client logged on, So this allows you to dump those as fast as possible to not possibly cause your program to abend.
So as you can see using this method, if you stopped/started the Skype client and your program, you would not receive any OLD stuff to process (Minus any read status messages"), since you have not sent a message yet, and in most cases, you should not receive a received message unless someone just sent a text message into the chat.
I guess what I am saying is it appears to me that sending, sent and received status messages don't queue up for you if you go away as a program/Skype Client, but you still do receive a read status message for ALL messages sent in the past.
I hope this makes sense, if not, please ask, because I know it is hard to grasp what is going on in multi-chats with the amount of status messages you can/will receive, and how to limit those to the ones you really want to process.