Пример #1
0
        //Needs be be triggered by an external source
        //Each invitiation needs to subscrib to a delegate in its fiend class. Then the friend class will trigger the OnMessageReceived. This is because receiving messages changes based on the implementation.(facebook , google , text ect)
        //When changes the status based on the analyzed sentiment then triggers status changed
        public void MessageReceived(string message)
        {
            _timer.Stop();

            var sentiment = InvitationAnalyzer.AnalyzeMessage(message);

            switch (sentiment)
            {
            case MessageSentiment.Yes:
                Status = InvitationStatus.Yes;
                break;

            case MessageSentiment.No:
                Status = InvitationStatus.No;
                break;

            case MessageSentiment.Unknown:
                Status = InvitationStatus.Unknown;
                break;
            }
            if (invitationStatusChanged != null)
            {
                invitationStatusChanged(this, EventArgs.Empty);
            }
            //Unsubscribe to message received
            Friend.MessageReceived -= MessageReceived;
        }
Пример #2
0
        //Needs be be triggered by an external source
        //Each invitiation needs to subscrib to a delegate in its fiend class. Then the friend class will trigger the OnMessageReceived. This is because receiving messages changes based on the implementation.(facebook , google , text ect)
        //When changes the status based on the analyzed sentiment then triggers status changed
        public void MessageReceived(string message)
        {
            Timer.Stop();

            var sentiment = InvitationAnalyzer.AnalyzeMessage(message);

            Console.WriteLine("Answer is " + sentiment);
            var ValidResponse = false;

            switch (sentiment)
            {
            case MessageSentiment.Yes:
                Status        = InvitationStatus.Yes;
                ValidResponse = true;
                break;

            case MessageSentiment.No:
                Status        = InvitationStatus.No;
                ValidResponse = true;
                //SendMessage("Too bad :(");
                break;

            case MessageSentiment.Unknown:
                Status = InvitationStatus.Unknown;
                SendMessage("Is that a yes or no?");
                break;
            }
            if (ValidResponse)
            {
                if (invitationStatusChanged != null)
                {
                    invitationStatusChanged(this, EventArgs.Empty);
                }
                //Unsubscribe to message received
                Friend.MessageReceived -= MessageReceived;
            }
        }