Ejemplo n.º 1
0
        public void onMessage(IClientSessionChannel channel, IMessage message)
        {
            var data = message.DataAsDictionary;
            #if DEBUG
            Console.WriteLine(message.ToString());
            #endif

            string command = this.GetString(data, "command");
            switch (command)
            {
                case "status":
                case "statusOK":
                case "statusFAIL":
                    string computer = this.GetString(data, "computer");
                    string statusMessage = this.GetString(data, "status");

                    Console.WriteLine(string.Format("{0} - {1}", computer, statusMessage));

                    Status status;
                    if (command == "statusOK")
                        status = Status.Successful;
                    else if (command == "statusFAIL")
                        status = Status.Failure;
                    else
                        status = Status.Information;

                    var handler = this.StatusReceived;
                    if (handler != null)
                        handler(this, new StatusEventArgs(computer, status, statusMessage));
                    break;
            }
        }
Ejemplo n.º 2
0
        /*int index = 0;
         * private void getString()
         * {
         *  while (index < 100)
         *  {
         *      Thread.Sleep(new Random().Next(2000));
         *      info_queue.Enqueue(new userstring("你好!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
         *          f.Width, new Random().Next(f.Height),Color.Black));
         *      index++;
         *  }
         * }*/

        private void OnMessageReceived(IClientSessionChannel channel, IMessage message, BayeuxClient client)
        {
            //Console.WriteLine(message.ToString());
            //Console.WriteLine(message.Channel);
            IDictionary <String, Object> data = message.DataAsDictionary;
            //Console.WriteLine(data["sender"]);
            //Console.WriteLine(data["msg"]);
            Color tempColor = Color.FromArgb(0xCC, 0xCC, 0xCC);

            switch (data["style"].ToString())
            {
            case "opinion":
                tempColor = Color.FromArgb(0xF8, 0xC3, 0x01); break;

            case "question":
                tempColor = Color.FromArgb(0xEF, 0x43, 0x40); break;

            case "answer":
                tempColor = Color.FromArgb(0x6E, 0x3F, 0xCF); break;

            case "chatting":
                tempColor = Color.FromArgb(0xA6, 0xD4, 0xF2); break;

            default:
                break;
            }
            info_queue.Enqueue(new userstring(data["sender"] + ":" + data["msg"],
                                              f.Width, new Random().Next(f.Height), tempColor));
        }
Ejemplo n.º 3
0
        public virtual bool UnsubscribeTopic(string topicName, IMessageListener listener = null)
        {
            if (null == topicName || (topicName = topicName.Trim()).Length == 0)
            {
                throw new ArgumentNullException("topicName");
            }

            //this.RefreshOAuthHeader();

            IClientSessionChannel channel = _bayeuxClient.GetChannel(Channel.Topic + "/" + topicName, false);

            if (null != channel)
            {
                if (null != listener)
                {
                    channel.Unsubscribe(listener);
                }
                else
                {
                    channel.Unsubscribe();
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        public void Run()
        {
            IClientSessionChannel callEventChannel = client.getChannel("/events/call");

            callEventChannel.unsubscribe(this);
            callEventChannel.subscribe(this);
        }
Ejemplo n.º 5
0
        private void tryToDelete(string mychannel)
        {
            //如果发哥的程序没有跟新就用下面这个调试
            //string url = "http://112.74.22.182:8080/BubbleServer/cometd";
            string url     = "http://112.74.22.182/cometd";
            var    options = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase)
            {
                // CometD server socket timeout during connection: 2 minutes
                { ClientTransport.MaxNetworkDelayOption, 120000 }
            };

            using (client = new BayeuxClient(url, new LongPollingTransport(options)))
            {
                if (client.Handshake(null, 3000))  // Handshake timeout: 30 seconds
                {
                    IClientSessionChannel channel = client.GetChannel("/service/deleteRoom");
                    channel.Subscribe(new CallbackMessageListener <BayeuxClient>(ReplyForDelete, client));
                    var data = new Dictionary <string, string>()
                    {
                        { "roomId", mychannel }
                    };
                    channel.Publish(data);
                }
            }
        }
Ejemplo n.º 6
0
        public void OnMessage(IClientSessionChannel channel, IMessage message)
        {
            var convertedJson = message.Json;

            _messages.Add(convertedJson);
            Logger.Debug($"Got message: {convertedJson}");
        }
Ejemplo n.º 7
0
        public void OnMessage(IClientSessionChannel channel, IMessage message)
        {
            var convertedJson = message.Json;
            var obj           = JsonConvert.DeserializeObject <Rootobject>(convertedJson);

            Console.WriteLine(convertedJson);
            Console.WriteLine(obj.data.sobject.Id + " " + obj.data.sobject.Name);
        }
Ejemplo n.º 8
0
        public void onMessage(IClientSessionChannel channel, IMessage message)
        {
            if (message.Channel.Equals(Channel_Fields.META_HANDSHAKE))
            {
                subscribed = false;
            }

            if (message.Channel.Equals(Channel_Fields.META_CONNECT) && message.Successful)
            {
                if (!subscribed)
                {
                    // Subscribe
                    callEventChannel.subscribe(this);
                    subscribed = true;
                }
            }

            if (message.ChannelId.ToString().Equals(channelId))
            {
                // Our message
                var data = message.DataAsDictionary;

                NameValueCollection nvc = new NameValueCollection(data.Count);
                foreach (var kvp in data)
                    nvc.Add(kvp.Key, kvp.Value.ToString());

                string command = nvc["command"];
                if (string.IsNullOrEmpty(command) || command == "status")
                    return;

                log.InfoFormat("Received command = {0}", command);

                string computer = nvc["computer"];
                if (!string.IsNullOrEmpty(computer) && !computer.Equals(Environment.MachineName, StringComparison.OrdinalIgnoreCase))
                    return;

                switch (command)
                {
                    case "deploy":
                        RaiseUpdateAvailable(nvc);
                        break;
                    case "ping":
                        PublishStatus("Pong");
                        break;
                }

                return;
            }

            try
            {
                log.Debug("Message on " + message.ChannelId.ToString() + "   Data: " + message.ToString());
            }
            catch
            {
            }
        }
Ejemplo n.º 9
0
        protected virtual void RemoveBayeuxErrorHandlers()
        {
            IClientSessionChannel channel = _bayeuxClient.GetChannel("/**", false);

            if (null != channel)
            {
                channel.RemoveListener(null);
            }
        }
Ejemplo n.º 10
0
        public void OnMessage(IClientSessionChannel channel, IMessage message)
        {
            var convertedJson = message.Json;
            var obj           = JsonConvert.DeserializeObject <CDCResponse>(convertedJson);

            Console.WriteLine(convertedJson);
            Console.WriteLine("Schema: " + obj.data.schema + " , Event:" + obj.data._event);
            Console.WriteLine("Payload: " + JsonConvert.SerializeObject(obj.data.payload));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Handles all Bayeux client errors.
        /// </summary>
        protected virtual void HandleBayeuxErrors()
        {
            IClientSessionChannel channel = _bayeuxClient.GetChannel("/**");

            if (null != channel)
            {
                channel.AddListener(new CallbackMessageListener <IStreamingAPIClient>(OnBayeuxClientFailure, this));
            }
        }
        /// <summary>
        /// Receives salesforce message from Platform Event
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="message"></param>
        public void OnMessage(IClientSessionChannel channel, IMessage message)
        {
            var msg = JsonConvert.DeserializeObject <CustomMessageEnvelope>(message.Json);

            _logger.LogDebug($"{nameof(CustomMessageListener)} payload: {message.Json}");

            var custName = msg.Data.Payload.CustomerName;
            var replayId = msg.Data.Event.ReplayId;

            _logger.LogDebug($"Customer Name: {custName} - ReplayId: {replayId}");
        }
 public void OnMessage(IClientSessionChannel channel, IMessage message)
 {
     try
     {
         subscriptions[message.Channel](channel, message, null);
     }
     catch (Exception exc)
     {
         log.Error("Execption handling OnMessage for " + message.Channel, exc);
     }
 }
Ejemplo n.º 14
0
 public void onMessage(IClientSessionChannel channel, IMessage message)
 {
     try
     {
         IDictionary <String, Object> data = message.DataAsDictionary;
         // Trigger callback:
         onCallEvent(data);
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            var longPollingTransport = new LongPollingTransport(null)
            {
                HeaderCollection = new WebHeaderCollection
                {
                    new NameValueCollection
                    {
                        {
                            "Content-Type",
                            "application/json"
                        },
                        {
                            "Authorization",
                            $"Bearer {accessToken}"
                        }
                    },
                },
                CookieCollection = new CookieCollection(),
            };

            var client = new BayeuxClient(url, new List <ClientTransport> {
                longPollingTransport
            });

            // Save the newReplayId in a reliable way. This is basically the last message processed
            // So when your application recovers a crash the next subscription should start from the last replay id processed
            var replayExtension = new ReplayExtension((changedChannel, newReplayId) => Console.WriteLine($"{changedChannel}: {newReplayId}"));

            replayExtension.SetReplayId(channelName, replayId);
            client.AddExtension(replayExtension);

            client.Handshake(new Dictionary <string, object>
            {
                { MessageFields.ReplayField, true }
            });

            var result = client.WaitFor(6000, new List <BayeuxClient.State> {
                BayeuxClient.State.Connected
            });

            // Subscription to channels
            IClientSessionChannel channel = client.GetChannel(channelName);
            var listener = new SimpleListener();

            channel.Subscribe(listener);
            //channel.Unsubscribe(listener);
            //replayExtension.SetReplayId(channelName, 100);
            //channel.Subscribe(listener);

            Thread.Sleep(Timeout.Infinite);
        }
        public void Initialize(StatisticsApi api)
        {
            WebHeaderCollection headers = new WebHeaderCollection();

            foreach (string key in api.Configuration.DefaultHeader.Keys)
            {
                switch (key)
                {
                case "x-api-key":
                case "Authorization":
                    headers.Add(key, api.Configuration.DefaultHeader[key]);
                    break;
                }
            }

            CookieCollection cookieCollection = CookieManager.Cookies.GetCookies(new Uri(api.GetBasePath()));

            /**
             * GWS currently only supports LongPolling as a method to receive events.
             * So tell the CometD library to negotiate a handshake with GWS and setup a LongPolling session.
             */
            LongPollingTransport transport = new LongPollingTransport(null);

            transport.CookieCollection = cookieCollection;
            transport.HeaderCollection = headers;

            bayeuxClient = new BayeuxClient(api.GetBasePath() + "/notifications", new List <CometD.NetCore.Client.Transport.ClientTransport>()
            {
                transport
            });

            bayeuxClient.Handshake();
            bayeuxClient.WaitFor(30000, new List <BayeuxClient.State>()
            {
                BayeuxClient.State.Connected
            });

            if (bayeuxClient.Connected)
            {
                foreach (Cookie cookie in cookieCollection)
                {
                    CookieManager.AddCookie(cookie);
                }

                foreach (string channelName in subscriptions.Keys)
                {
                    IClientSessionChannel channel = bayeuxClient.GetChannel(channelName);
                    channel.Subscribe(this);
                }
            }
        }
Ejemplo n.º 17
0
        public void onMessage(IClientSessionChannel channel, IMessage message)
        {
            try
            {
                IDictionary <String, Object> ext = (IDictionary <String, Object>)message.Ext["authentication"];
                userId   = ext["userId"].ToString();
                username = ext["username"].ToString();
            }
            catch (Exception)
            {
            }

            onLoginCompleted(message.Successful);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Processes the PushTopic message have just arrived.
        /// </summary>
        private static void OnMessageReceived(
            IClientSessionChannel channel, IMessage message, IStreamingAPIClient streamingClient)
        {
            // DEBUG
            _topicLogger.DebugFormat(CultureInfo.InvariantCulture,
                                     "Listener1 - Received PushTopic message for client '{1}', channel: {2}{0}{3}",
                                     Environment.NewLine, streamingClient.Id, channel.Id, JsonConvert.SerializeObject(message, Formatting.Indented));

            Thread.Sleep(3 * 60 * 1000);            // Emulates long-time processing method

            // DEBUG
            _topicLogger.DebugFormat(CultureInfo.InvariantCulture,
                                     "Listener1 - (After 3 minutes) Processed PushTopic message for client '{1}', channel: {2}{0}{3}",
                                     Environment.NewLine, streamingClient.Id, channel.Id, JsonConvert.SerializeObject(message, Formatting.Indented));
        }
Ejemplo n.º 19
0
        public NotifyClient(string cometURL, string channelId)
        {
            this.channelId = channelId;
            if (!this.channelId.StartsWith("/"))
                this.channelId = "/" + this.channelId;

            var transports = new List<ClientTransport>();
            transports.Add(new LongPollingTransport(null));

            client = new BayeuxClient(cometURL, transports);

            client.getChannel(Channel_Fields.META + "/**")
                .addListener(this);

            callEventChannel = client.getChannel(this.channelId);
        }
Ejemplo n.º 20
0
 public void onMessage(IClientSessionChannel channel, IMessage message)
 {
     if (message.Successful)
     {
         if (!connected)
         {
             connected = true;
         }
     }
     else
     {
         if (connected)
         {
             connected = false;
         }
     }
 }
Ejemplo n.º 21
0
 private void ReplyForDelete(IClientSessionChannel channel, IMessage message, BayeuxClient client)
 {
     //IDictionary<String, Object> data = message.DataAsDictionary;
     //string state = (string)data["status"];
     //string msg = (string)data["message"];
     //if (state.Equals("OK"))
     //{
     //    enterSuccess = status.success;
     //}
     //else
     //{
     //    if (MessageBox.Show(msg + "\nwould you like to enter this channel", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
     //        enterSuccess = status.success;
     //    else
     //        enterSuccess = status.fail;
     //}
 }
Ejemplo n.º 22
0
        /// <summary>
        /// <p>Receives a message (from the server) and process it.</p>
        /// <p>Processing the message involves calling the receive extensions and the channel listeners.</p>
        /// </summary>
        /// <param name="message">The mutable version of the message received.</param>
        public virtual void Receive(IMutableMessage message)
        {
            if (null == message)
            {
                throw new ArgumentNullException("message");
            }

            string id = message.Channel;

            if (String.IsNullOrEmpty(id))
            {
                throw new ArgumentException("Bayeux messages must have a channel, " + message);
            }

            if (!this.ExtendReceive(message))
            {
                return;
            }

            ChannelId             channelId;
            IClientSessionChannel channel = this.GetChannel(id, false);

            if (null != channel)
            {
                channelId = channel.ChannelId;
                channel.NotifyMessageListeners(message);
            }
            else
            {
                channelId = message.ChannelId;
            }

            foreach (string wildChannelName in channelId.Wilds)
            {
                //channelIdPattern = this.NewChannelId(channelPattern);
                //if (channelIdPattern != null && channelIdPattern.Matches(channelId))
                //{
                channel = this.GetChannel(wildChannelName, false);                // Wild channel
                if (channel != null)
                {
                    channel.NotifyMessageListeners(message);
                }
                //}
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Used to handle all Bayeux client errors.
        /// </summary>
        private static void OnBayeuxClientFailure(
            IClientSessionChannel channel, IMessage message, IStreamingAPIClient that)
        {
            if (null != message && !message.IsSuccessful && null == message.Data)
            {
                // DEBUG
                logger.InfoFormat(CultureInfo.InvariantCulture,
                                  "Failed message for client '{1}', channel: {2}{0}{3}",
                                  Environment.NewLine, that.Id, channel.Id, JsonConvert.SerializeObject(message, Formatting.Indented));

                object val;

                /*string error;
                 * if (message.TryGetValue(Message.ErrorField, out val)
                 *      && null != val
                 *      && (error = val.ToString().Trim()).Length > 0)
                 * {
                 *      // DEBUG
                 *      logger.ErrorFormat("Error during {0}: {1}", message.Channel, error);
                 * }*/

                Exception exception;
                if (message.TryGetValue(Message.ExceptionField, out val) &&
                    null != val &&
                    (exception = val as Exception) != null)
                {
                    // DEBUG
                    logger.Error("Exception during: " + message.Channel, exception);

                    try { that.RefreshOAuthHeader(); }
                    catch (Exception) { }
                }

                /*string failure = null;
                 * if (message.TryGetValue(Message.MessageField, out val)
                 *      && null != val
                 *      && (failure = val.ToString().Trim()).Length > 0)
                 * {
                 *      // DEBUG
                 *      logger.Error("Failed sending message: " + failure);
                 * }*/
            }
        }
Ejemplo n.º 24
0
        public virtual void SubscribeTopic(string topicName, IMessageListener listener)
        {
            if (null == topicName || (topicName = topicName.Trim()).Length == 0)
            {
                throw new ArgumentNullException("topicName");
            }
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            //this.RefreshOAuthHeader();

            IClientSessionChannel channel = _bayeuxClient.GetChannel(Channel.Topic + "/" + topicName);

            if (null != channel)
            {
                channel.Subscribe(listener);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Receives Salesforce message from Platform Event.
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="message"></param>
        public void OnMessage(IClientSessionChannel channel, IMessage message)
        {
            var msg = JsonConvert.DeserializeObject <CustomMessageEnvelope>(message.Json);

            _logger.LogDebug($"{nameof(CustomMessageListener)} payload: {message.Json}");

            var custName = msg.Data.Payload.CustomerName;
            var replayId = msg.Data.Event.ReplayId;

            _logger.LogDebug($"Customer Name: {custName} - ReplayId: {replayId}");

            var busEvent = _serviceProvider.GetRequiredService <IEventBus>();

            // publishes to SF custom Object.
            busEvent.Publish <TestEvent__c>(new BusEvent <TestEvent__c>
            {
                Name = nameof(TestEvent__c),
                Data = new TestEvent__c {
                    Name = custName
                }
            }).GetAwaiter().GetResult();
        }
Ejemplo n.º 26
0
        private void connect(String mychannel)
        {
            // Initializes a new BayeuxClient
            //string url = "http://112.74.22.182:8080/BubbleServer/cometd";
            string url     = "http://112.74.22.182/cometd";
            var    options = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase)
            {
                // CometD server socket timeout during connection: 2 minutes
                { ClientTransport.MaxNetworkDelayOption, 120000 }
            };

            using (client = new BayeuxClient(url, new LongPollingTransport(options)))
            {
                // Connects to the Bayeux server
                if (client.Handshake(null, 10000))  // Handshake timeout: 30 seconds
                {
                    // Subscribes to channels
                    IClientSessionChannel channel = client.GetChannel("/" + mychannel);
                    channel.Subscribe(new CallbackMessageListener <BayeuxClient>(OnMessageReceived, client));


                    /*
                     * // Publishes to channels
                     * var data = new Dictionary<string, string>()
                     * {
                     *  { "sender", "PC" },
                     *  { "msg","pc text!"}
                     * };
                     * channel.Publish(data);
                     */
                }

                /*else {
                 *  MessageBox.Show("Connect failed!");
                 *  statics = 1;
                 * }*/
            }
        }
Ejemplo n.º 27
0
 public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
 {
     Console.WriteLine(message);
     Google.ProtocolBuffers.IMessage msg = Util.restoreMessage(message);
 }
Ejemplo n.º 28
0
 public void onMessage(IClientSessionChannel channel, IMessage message)
 {
     logger.LogInformation(message.JSON);
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Callback invoked when a message is received on the given <paramref name="channel"/>.
 /// </summary>
 public void OnMessage(IClientSessionChannel channel, IMessage message)
 {
     // Specify what method to call when callbackAction completes
     _callback.BeginInvoke(channel, message, _stateObject, ExecAsyncCallback, null);
 }
Ejemplo n.º 30
0
 public void onMessage(IClientSessionChannel channel, IMessage message)
 {
     Trace.TraceInformation($"AccountUpdateHandler: received on {channel}: {message}");
 }
Ejemplo n.º 31
0
            public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
            {
                Console.WriteLine(message);
                Google.ProtocolBuffers.IMessage msg = Util.restoreMessage(message);
                if (msg.GetType().ToString().Equals("sally.AlexRangeRequest"))
                {
                    sally.AlexRangeRequest pos = (sally.AlexRangeRequest)msg;
                    String dump = pos.ToJson();

                    string filename = new System.Uri(pos.FileName).AbsolutePath;
                    foreach (RangeSelection i in pos.SelectionList)
                    {
                        moveSelectionTo(i, filename);
                    }

                    //int col = pos.SelectionList;
                    //int row = pos.Row;
                    //int sheet = pos.Sheet;
                    //RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet + "").Build();
                    //Microsoft.Office.Interop.Excel.Range range = Globals.ThisAddIn.Application.ActiveSheet.Cells[click.StartRow + 1, click.StartCol + 1].Select();

                }
                if (msg.GetType().ToString().Equals("sally.SaveASM"))
                {
                    SaveASM asm = (SaveASM)msg;
                    saveSemanticMap(asm.SemanticData);

                }
                /*    if (msg.GetType().ToString().Equals("sally.HighlightRanges"))
                    {
                        // Change to an Array or ArrayList. Might be faster.
                        List<HighlightRange> arr = new List<HighlightRange>(((HighlightRanges)msg).RangeList);

                        String activeSheet = Globals.ThisAddIn.Application.ActiveSheet.Name;    // Get the name of the active sheet
                        int i=0;
                        foreach (HighlightRange el in arr)
                        {
                            if(el.Sheet.Equals(activeSheet, StringComparison.InvariantCultureIgnoreCase)){
                                selectMultipleRanges(new List<RangeSelection> (el.RangesList), el.Sheet);
                            //Highlight range
                                break;
                            }
                            i++;
                        }
                        if(i>=arr.Count && arr.Count >0){
                            selectMultipleRanges(new List<RangeSelection>(arr[0].RangesList), arr[0].Sheet);
                        }

                        int col = ((NavigateTo)msg).Col;
                        int row = ((NavigateTo)msg).Row;
                        String sheet = ((NavigateTo)msg).Sheet;
                        RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet).Build();
                        moveCursorAt(click);

                    }*/
            }
Ejemplo n.º 32
0
 void OnStatisticUpdate(IClientSessionChannel channel, IMessage message, BayeuxClient client)
 {
     log.Debug("\n\n\n++++OnStatisticsUpdate++++ received: \n" + message.ToString() + "\n\n\n");
 }
Ejemplo n.º 33
0
 public void onMessage(IClientSessionChannel channel, IMessage message)
 {
     Console.WriteLine(message.JSON);
 }
Ejemplo n.º 34
0
 void OnServiceStateChanged(IClientSessionChannel channel, IMessage message, BayeuxClient client)
 {
     log.Debug("++++OnServiceStateChanged++++ received: " + message.ToString());
 }
Ejemplo n.º 35
0
		private static void WaitForNoneReconnection(
			IClientSessionChannel channel, IMessage message, ManualResetEvent latch)
		{
			if (null != message && null != latch)
			{
				string action = GetAdviceAction(message.Advice, Message.ReconnectNoneValue);
				if (Message.ReconnectNoneValue.Equals(action, StringComparison.OrdinalIgnoreCase))
				{
					latch.Set();// Signal()
					// DEBUG
					logger.InfoFormat("None reconnection message was found, signal Latch#{0}", latch.GetHashCode());
				}
			}
		}
Ejemplo n.º 36
0
            public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
            {
                Console.WriteLine(message);
                Google.ProtocolBuffers.IMessage msg = Util.restoreMessage(message);
                if (msg.GetType().ToString().Equals("sally.CellPosition"))
                {
                    CellPosition pos = (CellPosition)msg;
                    int col = pos.Col;
                    int row = pos.Row;
                    int sheet = pos.Sheet;
                    RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet + "").Build();
                    moveCursorAt(click);

                }
                if (msg.GetType().ToString().Equals("sally.SaveASM"))
                {
                    SaveASM asm = (SaveASM)msg;
                    saveSemanticMap(asm.SemanticData);

                }
                /*    if (msg.GetType().ToString().Equals("sally.HighlightRanges"))
                    {
                        // Change to an Array or ArrayList. Might be faster.
                        List<HighlightRange> arr = new List<HighlightRange>(((HighlightRanges)msg).RangeList);

                        String activeSheet = Globals.ThisAddIn.Application.ActiveSheet.Name;    // Get the name of the active sheet
                        int i=0;
                        foreach (HighlightRange el in arr)
                        {
                            if(el.Sheet.Equals(activeSheet, StringComparison.InvariantCultureIgnoreCase)){
                                selectMultipleRanges(new List<RangeSelection> (el.RangesList), el.Sheet);
                            //Highlight range
                                break;
                            }
                            i++;
                        }
                        if(i>=arr.Count && arr.Count >0){
                            selectMultipleRanges(new List<RangeSelection>(arr[0].RangesList), arr[0].Sheet);
                        }

                        int col = ((NavigateTo)msg).Col;
                        int row = ((NavigateTo)msg).Row;
                        String sheet = ((NavigateTo)msg).Sheet;
                        RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet).Build();
                        moveCursorAt(click);

                    }*/
            }
Ejemplo n.º 37
0
 public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
 {
     if (message.Successful)
     {
         Console.WriteLine("had something on " + message.Channel);
         Console.WriteLine("namely " + message.JSON);
     }
 }
Ejemplo n.º 38
0
 public void onMessage(IClientSessionChannel channel, IMessage message)
 {
     #if DEBUG
     Console.WriteLine("META: " + message.ToString());
     #endif
 }