Exemplo n.º 1
0
        public static bool Authenticate(string serviceName, string user, string password)
        {
            //Initialize
            PamStatus           lastReturnedValue   = PamStatus.PAM_SUCCESS;
            IntPtr              pamHandle           = IntPtr.Zero;
            PamConv             conversation        = new PamConv();
            ConversationHandler conversationHandler = new ConversationHandler(password);

            conversation.ConversationCallback = conversationHandler.HandlePamConversation;

            try {
                //Start
                lastReturnedValue = Pam.pam_start(serviceName, user, conversation, ref pamHandle);
                if (lastReturnedValue != PamStatus.PAM_SUCCESS)
                {
                    return(false);
                }
                //Authenticate - Verifies username and password
                lastReturnedValue = Pam.pam_authenticate(pamHandle, AuthenticateFlags);
                if (lastReturnedValue != PamStatus.PAM_SUCCESS)
                {
                    return(false);
                }
                //Account Management - Checks that account is valid, checks account expiration, access restrictions.
                lastReturnedValue = Pam.pam_acct_mgmt(pamHandle, AccountManagementFlags);
                if (lastReturnedValue != PamStatus.PAM_SUCCESS)
                {
                    return(false);
                }
            } finally {
                lastReturnedValue = Pam.pam_end(pamHandle, lastReturnedValue);
            }

            return(true);
        }
Exemplo n.º 2
0
	//Initialize Dependencies
	public override void Init (){
		base.Init ();
		
		if (Instance == null) {
			Instance = this;		
		}

		m_conversationHistories = new Dictionary<string,List<DialogueLine> > ();
		m_conversationDisplays = new List<ConversationDisplayUnit> ();
	}
 /// <summary>
 /// Implements the singleton pattern on this class. Only a single instance of this class will exist in the whole game and it can be accessed by anyone.
 /// </summary>
 void InitSingleton()
 {
     if (conversationHandler == null)
     {
         conversationHandler = this;
     }
     else if (conversationHandler != this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 4
0
    //Initialize Dependencies
    public override void Init()
    {
        base.Init();

        if (Instance == null)
        {
            Instance = this;
        }

        m_conversationHistories = new Dictionary <string, List <DialogueLine> > ();
        m_conversationDisplays  = new List <ConversationDisplayUnit> ();
    }
        public void TestInProgress()
        {
            var handler    = new ConversationHandler();
            var inProgress = new Activity()
            {
                Text = "not yet still doing help"
            };

            var response = handler.GetResponse(inProgress);

            Assert.AreEqual("keep going", response.Value);
        }
        public void TestNewUser()
        {
            var handler = new ConversationHandler();
            var newUser = new Activity()
            {
                Text = "hello hi welcome i am i'm",
                From = new ChannelAccount((new Guid()).ToString(), "tester")
            };

            var response = handler.GetResponse(newUser);

            Assert.AreEqual(GeneralResponses.WelcomeText, response.Value);
        }
        public void TestNewChallenge()
        {
            var handler       = new ConversationHandler();
            var challengeDone = new Activity()
            {
                Text = "finished done"
            };
            var act = handler.GetResponse(challengeDone);

            var response = handler.GetResponse(act);

            Assert.AreEqual("new challenge", response.Value);
        }
Exemplo n.º 8
0
    // Adapted from the Watson Unity SDK., so send results to the Conversation and Tone analyzer, so the Octopus can respond to the results from these.
    private void OnRecognize(SpeechRecognitionEvent result, Dictionary <string, object> customData)
    {
        if (result != null && result.results.Length > 0)
        {
            foreach (var res in result.results)
            {
                foreach (var alt in res.alternatives)
                {
                    string text = string.Format("{0} ({1}, {2:0.00})\n", alt.transcript, res.final ? "Final" : "Interim", alt.confidence);
                    if (firstGuess)
                    {                                                                           // This is where we update the Debug Panel to move everything up one if this is our first guess for a new sentence.
                        speechToTexta2.text = speechToTexta1.text;
                        speechToTexta1.text = ResultsField.text;
                    }
                    firstGuess        = false;                                                                  // subsequent entries into this OnRecognize function will not update the history in the debug log...
                    ResultsField.text = text;                                                                   // ...but will update the current speech results field.

                    Log.Debug("SpeechToTextHandler.OnRecognize()", text);

                    if (res.final)                                                                              // If we've got the final response for this sentence...
                    {
                        ResultsField.text = text;
                        ConversationHandler c = gameObject.GetComponent <ConversationHandler>();
                        c.AskQuestion(alt.transcript);                                                              // Send the text to the Conversation Handler to get and process the intent
                        ToneHandler tone = gameObject.GetComponent <ToneHandler>();
                        tone.GetTone(alt.transcript);                                                               // And send to the ToneHandler to get and process the Tone.
                        firstGuess = true;                                                                          // The next time into this function will be the first guess of the next sentence.
                    }
                }

                /* More data if required -  from the Watson Unity SDK Example
                 * if (res.keywords_result != null && res.keywords_result.keyword != null)
                 * {
                 * foreach (var keyword in res.keywords_result.keyword)
                 * {
                 * Log.Debug("SpeechToTextHandler.OnRecognize()", "keyword: {0}, confidence: {1}, start time: {2}, end time: {3}", keyword.normalized_text, keyword.confidence, keyword.start_time, keyword.end_time);
                 * }
                 * }
                 *
                 * if (res.word_alternatives != null)
                 * {
                 * foreach (var wordAlternative in res.word_alternatives)
                 * {
                 * Log.Debug("SpeechToTextHandler.OnRecognize()", "Word alternatives found. Start time: {0} | EndTime: {1}", wordAlternative.start_time, wordAlternative.end_time);
                 * foreach (var alternative in wordAlternative.alternatives)
                 * Log.Debug("SpeechToTextHandler.OnRecognize()", "\t word: {0} | confidence: {1}", alternative.word, alternative.confidence);
                 * }
                 * } */
            }
        }
    }
Exemplo n.º 9
0
        public void Activate(Entity playerEntity, Entity otherEntity)
        {
            var entity = (Entity)Entity;
            var model  = entity.Model;

            var conversation = model.CurrentConversation;

            if (conversation == null)
            {
                return;
            }

            CharacterSpriteComponent spriteComp = playerEntity.GetComponent <CharacterSpriteComponent> ();

            spriteComp.LookAt((Entity)Entity);

            ConversationHandler.StartConversation(playerEntity, (Entity)Entity, conversation.Item1, conversation.Item2);
        }
Exemplo n.º 10
0
    public bool handleState(string connectedTo, SocketController controller, string operatorSocket, ConversationHandler convHandle, StrikeCounter counter)
    {
        if (previousState != state)
        {
            Debug.Log(incomingPort + " has changed from " + previousState + " to " + state);
        }

        switch (state)
        {
        case State.UNANSWERED:
            if (previousState != state)
            {
                controller.setLED(incomingPort, Socket.LEDColor.Red_Flash);
                unansweredTimer.Start();
                previousState = state;
            }

            if (unansweredTimedout)
            {
                state = State.DISCONNECT_NEGATIVE;
            }
            else if (connectedTo == operatorSocket)
            {
                state = State.OPERATOR_CONNECTED;
            }
            else if (connectedTo != null)
            {
                state = State.WRONG_PERSON_CONNECTED;
            }
            break;

        case State.OPERATOR_CONNECTED:
            if (previousState != state)
            {
                Debug.Log("OH HI THE ANSWER IS " + targetPort);
                convHandle.setConversation(operatorConv, true);
                if (controller.isTapped(incomingPort))
                {
                    Debug.Log("TAPPED");
                    convHandle.setConversation(operatorConv, false);
                }
                controller.setLED(incomingPort, Socket.LEDColor.Green);
                controller.setLED(operatorSocket, Socket.LEDColor.Green);

                // Only call once, they can jump back to this state, and it shouldn't restart the timer.
                if (!afterOperatorTimeoutCalled)
                {
                    afterOperatorTimeoutCalled = true;
                    afterOperatorTimer.Start();
                }

                previousState = state;
            }
            //EVERY FRAME

            if (afterOperatorTimedout)   // connected too long
            {
                state = State.DISCONNECT_NEGATIVE;
            }
            else if (connectedTo != operatorSocket)
            {
                state = State.DISCONNECTED_AFTER_OPERATOR;
            }
            break;

        case State.DISCONNECTED_AFTER_OPERATOR:
            if (previousState != state)
            {
                controller.setLED(incomingPort, Socket.LEDColor.Red_Flash);
                controller.setLED(operatorSocket, Socket.LEDColor.Off);
                previousState = state;
            }
            if (afterOperatorTimedout)               // connected too long
            {
                state = State.DISCONNECT_NEGATIVE;
            }
            else if (connectedTo == targetPort)
            {
                state = State.TALKING;
            }
            else if (connectedTo == operatorSocket)
            {
                state = State.OPERATOR_CONNECTED;
            }
            else if (connectedTo != null)
            {
                state = State.WRONG_PERSON_CONNECTED;
            }
            break;

        case State.TALKING:
            if (previousState != state)
            {
                if (controller.isTapped(incomingPort))
                {
                    convHandle.setConversation(tappedConv, false);
                }
                controller.setLED(incomingPort, Socket.LEDColor.Green);
                controller.setLED(targetPort, Socket.LEDColor.Green);

                // Lock both
                controller.LockSocket(incomingPort);
                controller.LockSocket(targetPort);

                convoTimer.Start();
                previousState = state;
            }
            if (convoTimedout && !controller.isTapped(incomingPort))                // convo success
            {
                state = State.DISCONNECT_POSITIVE;
            }
            else if (controller.isTapped(incomingPort))
            {
                bool convend = !tappedConv.hasNextSentance();
                bool textend = !convHandle.txtwritetapped.speaking;
                if (convend && textend)
                {
                    state = State.DISCONNECT_POSITIVE;
                }
            }
            break;

        case State.DISCONNECT_POSITIVE:
            if (previousState != state)
            {
                controller.happyAt(incomingPort);
                controller.setLED(incomingPort, Socket.LEDColor.Off);
                controller.setLED(targetPort, Socket.LEDColor.Off);

                // Unlock both
                controller.UnlockSocket(incomingPort);
                controller.UnlockSocket(targetPort);

                disconnectGraceTimer.Start();
                previousState = state;
            }
            // TODO Positive feedback
            if (disconnectGraceTimedout)
            {
                controller.unreserveForCall(incomingPort);
                controller.unreserveForCall(targetPort);
                // we want to die, return false!
                return(false);
            }
            break;

        case State.DISCONNECT_NEGATIVE:
            if (previousState != state)
            {
                controller.sadAt(incomingPort);
                counter.addCitation();
                controller.setLED(incomingPort, Socket.LEDColor.Off);
                controller.setLED(targetPort, Socket.LEDColor.Off);
                if (connectedTo != null)
                {
                    controller.setLED(connectedTo, Socket.LEDColor.Off);
                    controller.UnlockSocket(connectedTo);
                    controller.unreserveForCall(connectedTo);
                }

                // Unlock both
                controller.UnlockSocket(incomingPort);
                controller.UnlockSocket(targetPort);

                disconnectGraceTimer.Start();
                previousState = state;
            }
            if (disconnectGraceTimedout)
            {
                controller.unreserveForCall(incomingPort);
                controller.unreserveForCall(targetPort);
                // we want to die, return false!
                return(false);
            }
            break;

        case State.WRONG_PERSON_CONNECTED:
            if (previousState != state)
            {
                controller.setLED(incomingPort, Socket.LEDColor.Red);
                controller.setLED(connectedTo, Socket.LEDColor.Red);

                // Lock both
                controller.LockSocket(incomingPort);
                controller.LockSocket(connectedTo);
                controller.reserveForCall(connectedTo);

                wrongConvoTimer.Start();
                previousState = state;
            }
            if (wrongConvoTimedout)
            {
                state = State.DISCONNECT_NEGATIVE;
            }
            break;
        }
        // We still want to live, return true!
        return(true);
    }
 private void Start()
 {
     text = GetComponent <Text>();
     conversationHandler = transform.parent.GetComponentInParent <ConversationHandler>();
 }
Exemplo n.º 12
0
 private void Start()
 {
     ch = GameObject.Find("ConversationHandler").GetComponent <ConversationHandler>();
 }