예제 #1
0
        private void ClientOnStompCoreFrameArrived(object sender, StompCoreFrameArrivedEventArgs args)
        {
            // analyze frame
            switch (args.Frame.Command)
            {
            case StompCommands.Connected:
            {
                // CONNECTED FRAME received set core as connected
                OnStatusChanged(EnumStompClientStatus.Connected);
                break;
            }

            case StompCommands.Disconnect:
            {
                // CONNECTED FRAME received set core as connected
                OnStatusChanged(EnumStompClientStatus.Disconnected);
                break;
            }

            case StompCommands.Error:
            {
                OnError(_error);
                break;
            }

            case StompCommands.Receipt:
            {
                OnReceipt(args.Frame);
                break;
            }

            case StompCommands.Message:
            {
                RaiseFrameArriveEventInSeparateThread(args);
                break;
            }

            default:
            {
                // pass frame upwards
                RaiseFrameArriveEventInSeparateThread(args);
                break;
            }
            }
        }
예제 #2
0
        private void OnFrameArrived(StompCoreFrameArrivedEventArgs e)
        {
            // Remove messages from inQueue if there are more than 20
            _inQueue.Enqueue(e.Frame);
            StompFrame frame;

            while (_inQueue.Count > 20)
            {
                _inQueue.TryDequeue(out frame);
            }

            if (StompClientFrameArrivedEvent != null)
            {
                StompTrace.Info("Stomp Client Frame arrived: \n{0}", e.Frame.GetFrame());
                StompClientFrameArrivedEvent(this, new StompClientFrameArrivedArgs {
                    Frame = e.Frame, Time = e.Time
                });
            }
        }
예제 #3
0
 private void RaiseFrameArriveEventInSeparateThread(StompCoreFrameArrivedEventArgs e)
 {
     // Start event in new thread, to avoid blocking core
     Task.Factory.StartNew(() => OnFrameArrived(e));
 }