예제 #1
0
 void Skype_MessageStatus(SKYPE4COMLib.ChatMessage pMessage, TChatMessageStatus Status)
 {
     try
     {
         if (Status.Equals(TChatMessageStatus.cmsReceived))
         {
             Trigger();
         }
     }
     catch (Exception ex)
     {
         ErrorLog.AddError(ErrorType.Failure, string.Format(Strings.Error_EventCantBeTriggered, Strings.ReceiveChatMessage_Title));
         Logger.Write(ex);
     }
 }
예제 #2
0
        /// <summary>
        /// Change status message
        /// </summary>
        /// <remarks>
        /// Chat messages
        /// </remarks>
        /// <param name="chatmessage">talk to person (always) one person</param>
        /// <param name="status">status of talk</param>
        private void ChangeMessageStatus(SKYPE4COMLib.ChatMessage chatmessage, SKYPE4COMLib.TChatMessageStatus status)
        {
            try
            {
                //chat receive
                if ((status == TChatMessageStatus.cmsReceived) &&
                    (chatmessage.Type == TChatMessageType.cmeSaid))
                {
                    List <string> listOfRecipients = new List <string>();
                    if (chatmessage.Chat.Type == TChatType.chatTypeMultiChat)
                    {
                        //conferenc talk > 2 users
                        UserCollection collectionOfUsers = chatmessage.Chat.Members as UserCollection;
                        foreach (User oneUser in collectionOfUsers)
                        {
                            listOfRecipients.Add(oneUser.Handle);
                        }
                    }
                    else
                    {
                        //pair talk < 3 users
                        listOfRecipients.Add(skype.CurrentUser.Handle);
                    }
                    ChatMessage receiveChatMessage = new ChatMessage(chatmessage.FromHandle,
                                                                     listOfRecipients,
                                                                     chatmessage.Body,
                                                                     chatmessage.Timestamp,
                                                                     chatmessage.Chat.Blob);
                    interfaceToOperate.AddMessage(receiveChatMessage, TypeConversation.Chat);
                }

                //chat send
                else if ((status == TChatMessageStatus.cmsSending) &&
                         (chatmessage.Type == TChatMessageType.cmeSaid))
                {
                    List <string> listOfRecipients = new List <string>();
                    string        recipient        = string.Empty;
                    if (chatmessage.Chat.Type == TChatType.chatTypeMultiChat)
                    {
                        //conferenc talk > 2 users
                        UserCollection collectOfUsers = chatmessage.Chat.Members as UserCollection;
                        foreach (User oneUser in collectOfUsers)
                        {
                            if (oneUser.Handle != skype.CurrentUser.Handle)
                            {
                                //if itsn't me
                                listOfRecipients.Add(oneUser.Handle);
                            }
                        }
                    }
                    else
                    {
                        //talk in one person
                        recipient = chatmessage.Chat.DialogPartner;
                        listOfRecipients.Add(recipient);
                    }
                    ChatMessage receiveChatMessage = new ChatMessage(chatmessage.FromHandle,
                                                                     listOfRecipients,
                                                                     chatmessage.Body,
                                                                     chatmessage.Timestamp,
                                                                     chatmessage.Chat.Blob);
                    interfaceToOperate.AddMessage(receiveChatMessage, TypeConversation.Chat);
                }
            }
            catch (Exception ex)
            {
                ErrorCode = ex.Message;
            }
        }