示例#1
0
        /// <inheritdoc/>
        /// <remarks>
        /// Handles the following event types: CloseSessionMessage, ChatMessage, 
        /// ExecutionResultMessage.
        /// </remarks>
        protected override void ApplicationConnectionReceived(object sender, ReceivedEventArgs e)
        {
            if (e.Message is CloseSessionMessage)
            {
                session.Reset();
            }
            else if (e.Message is ChatMessage)
            {
                session.OnReceiveChatMessage(new ReceiveChatMessageEventArgs((ChatMessage)e.Message));
            }
            else if (e.Message is ExecutionResultMessage)
            {
                ExecutionResultMessage erm = (ExecutionResultMessage)e.Message;

                ExecutionResult result = new ExecutionResult();

                session.OnStartedExecution(new StartedExecutionEventArgs((int)session.ApplicationConnection.Tag, result));

                result.OnExecutionChanged(new ExecutionChangedEventArgs(erm.StandardOut));
                result.OnFinishedExecution(new FinishedExecutionEventArgs(0, erm.StandardOut));
            }
            else
            {
                Logger.WarnFormat("Received unsupported message on application connection: {0}", e.Message.GetType().Name);
                base.ApplicationConnectionReceived(sender, e);
            }
        }
示例#2
0
 /// <inheritdoc/>
 /// <remarks>
 /// Handles the following events:
 /// <list type="bullet">
 ///     <item>
 ///         <term>"HI 0"</term>
 ///         <description>Initial handshake</description>
 ///     </item>
 /// 
 ///     <item>
 ///         <term>"HI 1"</term>
 ///         <description>Second handshake. Afer receiving this, we will change to 
 ///         the <see cref="InitializationState">Initializationtate</see>.</description>
 ///     </item>       
 /// </list>
 /// </remarks>
 protected override void ApplicationConnectionReceived(object sender, ReceivedEventArgs e)
 {
     if ((string)e.Message == "HI 0")
     {
         Console.WriteLine(session.SiteId.ToString() + ": " + e.Message);
         session.ApplicationConnection.Send("HI 1");
     }
     else if ((string)e.Message == "HI 1")
     {
         Console.WriteLine(session.SiteId.ToString() + ": " + e.Message);
         session.ApplicationConnection.Send("HI 1");
         session.ActivateState(new InitializationState(session));
     }
     else
     {
         base.ApplicationConnectionReceived(sender, e);
     }
 }
示例#3
0
 internal void ReceiveMessage(ReceivedEventArgs e)
 {
     // To avoid strange skype behavior which result in hard to understand
     // call stacks, we don't immediately dispatch, but use a dispatcher
     // thread with its own stack frame.
     lock(receiveQueue)
     {
         receiveQueue.Enqueue(e);
         Monitor.PulseAll(receiveQueue);
     }
 }
示例#4
0
 /// <summary>
 /// Handles messages received from the session's application connection.
 /// </summary>
 /// <param name="sender">The issuer of the event.</param>
 /// <param name="e">The event data, describing the packet that was received.</param>
 protected virtual void ApplicationConnectionReceived(object sender, ReceivedEventArgs e)
 {
 }
        private void InvokedConnectionReceived(object sender, ReceivedEventArgs e)
        {
            lock(this)
            {
                if (e.Message is DiffMessage)
                {
                    Debug.Assert(TokenState == TokenState.WaitingForToken);
                    TokenRequestSent = false;
                    DiffMessage diffMessage = (DiffMessage)e.Message;

                    ApplyPatches(diffMessage);
                    TokenState = TokenState.HavingToken;

                    if (HasChanged)
                    {
                        HasChanged = false;
                        SendPatches();
                        TokenState = TokenState.WaitingForToken;
                    }
                }
                else if (e.Message is TokenRequestMessage)
                {
                    if (TokenState == TokenState.HavingToken)
                    {
                        HasChanged = false;
                        SendPatches();
                        TokenState = TokenState.WaitingForToken;
                    }
                }
                else
                {
                    throw new Exception(String.Format("Encountered unknown message type '{0}'", e.Message.GetType().Name));
                }
            }
        }
 private void ConnectionReceived(object sender, ReceivedEventArgs e)
 {
     Context.Invoke(delegate {
         InvokedConnectionReceived(sender, e);
     });
 }