Пример #1
0
        static bool AssertExpectedCommandFrame(Frame frame, string expectedFrameCommand)
        {
            // If error
            if (frame.Command == StompCommands.Error)
            {
                // Using the incoming frame, Interpret will create a new instance of a sub-class
                // of Frame depending on the Command. If the frame is a HEARTBEAT, the same frame
                // will be returned. Possible sub-classes: ConnectedFrame, ErrorFrame, MessageFrame,
                // ReceiptFrame.
                // Interpret throws exception if the incoming frame is malformed (not standard).
                ErrorFrame errFrame = StompInterpreter.Interpret(frame) as ErrorFrame;

                Console.WriteLine("ERROR RESPONSE");
                Console.WriteLine("Message : " + errFrame.Message);

                return(false);
            }

            if (frame.Command != expectedFrameCommand)
            {
                Console.WriteLine("UNEXPECTED FRAME.");
                Console.WriteLine(frame.ToString());

                return(false);
            }

            return(true);
        }
Пример #2
0
 public ErrorFrameException(ErrorFrame errorFrame)
     : base(errorFrame != null ? errorFrame.Message : null)
 {
     if (errorFrame == null)
     {
         throw new ArgumentNullException("errorFrame");
     }
     ErrorFrame = errorFrame;
 }
Пример #3
0
        /*
         *  STOMP 1.2 servers MUST set the following headers:
         *
         *  version : The version of the STOMP protocol the session will be using. See Protocol Negotiation for more details.
         *  STOMP 1.2 servers MAY set the following headers:
         *
         *  heart-beat : The Heart-beating settings.
         *
         *  session : A session identifier that uniquely identifies the session.
         *
         *  server : A field that contains information about the STOMP server. The field MUST contain a server-name field and MAY be followed by optional comment fields delimited by a space character.
         *
         *  The server-name field consists of a name token followed by an optional version number token.
         *
         *  server = name ["/" version] *(comment)
         *
         *  Example:
         *
         *  server:Apache/1.3.9
         */
        public static StompFrame CreateConnectedFrame(StompFrame connectFrame, string session)
        {
            StompFrame ConnectedFrame = new StompFrame(StompCommands.Connected);

            if (connectFrame.Headers.ContainsKey(StompHeaders.AcceptVersion))
            {
                int maxVersion = -1;
                foreach (var v in connectFrame.Headers[StompHeaders.AcceptVersion].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Reverse())
                {
                    if (v == "1.2")
                    {
                        maxVersion = 2;
                        break;
                    }
                    else if (v == "1.1")
                    {
                        maxVersion = maxVersion > 1 ? maxVersion : 1;
                    }
                    else if (v == "1.0")
                    {
                        maxVersion = maxVersion > 0 ? maxVersion : 0;
                    }
                }
                if (maxVersion > -1)
                {
                    ConnectedFrame[StompHeaders.Version] = "1." + maxVersion;
                }

                if (!ConnectedFrame.Headers.ContainsKey(StompHeaders.Version))
                {
                    string     tips       = "Version Unsupport";
                    string     detail     = "XStomp Server Supported Protocol Versions Are 1.0,1.1,1.2";
                    ErrorFrame errorFrame = new ErrorFrame(tips, detail, connectFrame);
                    return(errorFrame);
                }
            }
            else
            {
                // Only Support Stomp 1.0
                // 没有这个头信息,表示只支持1.0版本的协议
                ConnectedFrame[StompHeaders.Version] = "1.0";
            }

            //
            ConnectedFrame[StompHeaders.Session] = session; // headers.ContainsKey(StompHeaders.Session) ? headers[StompHeaders.Session] : session;

            // if you want support client try connect host ,Code here
            // 客户端希望连接的主机名,如果你要实现得更完整,在这里可以实现.我就默认支持此版本server了
            ConnectedFrame[StompHeaders.Server] = "XStompServer/1.0.0"; //ConnectedFrame.Headers.ContainsKey(StompHeaders.Server) ? ConnectedFrame[StompHeaders.Server] : "StompServerX/1.0.0";

            // close HeartBeat ,If you want support, Code here
            // 默认关闭心跳机制
            ConnectedFrame[StompHeaders.Heartbeat] = "0,0"; //ConnectedFrame.Headers.ContainsKey(StompHeaders.Heartbeat) ? ConnectedFrame.Headers[StompHeaders.Heartbeat] : "0,0";

            return(ConnectedFrame);
        }
Пример #4
0
        public void SetDialogFrame(object content)
        {
            bool isEmpty   = content == null;
            var  focusMode = (isEmpty ? MainFrame_KeyboardNavigationMode_Default : KeyboardNavigationMode.None);

            KeyboardNavigation.SetTabNavigation(MainFrame, focusMode);
            KeyboardNavigation.SetTabNavigation(OverlayFrame, focusMode);
            Keyboard.ClearFocus();
            ErrorFrame.Navigate(content);
        }
        private void OnFrame(ServerClient arg1, MessageFrame arg2)
        {
            var destination = arg2.Destination;
            IMessagingService service;
            if (!_items.TryGetValue(destination, out service))
            {
                if (destination.StartsWith("topic/"))
                {
                    if (!AllowDynamicTopics)
                    {
                        var errorFrame = new ErrorFrame("Topics must exist before messages are sent. Cannot create " + destination);
                        //arg1.Send(errorFrame);
                    }
                }

            }
        }
Пример #6
0
        public async void ErrorVisible_Changed(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (Animation)
            {
                return;
            }
            if (e.PropertyName == "IsVisible")
            {
                if (ErrorFrame.IsVisible)
                {
                    Animation = true;
                    ErrorFrame.TranslationX  = -300;
                    ButtonRetry.TranslationX = 300;

                    new Thread(async() =>
                    {
                        await ErrorFrame.TranslateTo(ErrorFrame.TranslationX + 320, ErrorFrame.TranslationY, 150);
                        await ErrorFrame.TranslateTo(ErrorFrame.TranslationX - 50, ErrorFrame.TranslationY, 40);
                        await ErrorFrame.TranslateTo(ErrorFrame.TranslationX + 50, ErrorFrame.TranslationY, 50);
                        await ErrorFrame.TranslateTo(ErrorFrame.TranslationX - 20, ErrorFrame.TranslationY, 40);
                    }).Start();

                    new Thread(async() =>
                    {
                        await ButtonRetry.TranslateTo(ButtonRetry.TranslationX - 320, ButtonRetry.TranslationY, 150);
                        await ButtonRetry.TranslateTo(ButtonRetry.TranslationX + 50, ButtonRetry.TranslationY, 40);
                        await ButtonRetry.TranslateTo(ButtonRetry.TranslationX - 50, ButtonRetry.TranslationY, 50);
                        await ButtonRetry.TranslateTo(ButtonRetry.TranslationX + 20, ButtonRetry.TranslationY, 40);
                    }).Start();
                    await Task.Delay(300);

                    Animation = false;
                }
                else
                {
                    ErrorFrame.TranslationX  = -300;
                    ButtonRetry.TranslationX = 300;
                }
            }
        }
Пример #7
0
 public RemoteErrorException(ErrorFrame error)
     : base(error.Message)
 {
 }
Пример #8
0
 public ErrorReceivedEventArgs(ErrorFrame errorFrame)
 {
     this.ErrorFrame = errorFrame;
 }