Exemplo n.º 1
0
 public void Enqueue(IBayeuxMessage @event)
 {
     if (!_queue.IsAddingCompleted)
     {
         _queue.Add(@event);
     }
 }
Exemplo n.º 2
0
        private void MeCallback(IBayeuxMessage message)
        {
            var jsonString   = message.Data.ToString();
            var notification = JsonConvert.DeserializeObject <Notifications.Notification>(jsonString);

            Console.WriteLine($"Received {message.Data.ToString()} for ME! at {System.DateTime.Now.ToShortTimeString()}");

            try
            {
                var handler = this.NotificationReceived;
                handler?.Invoke(this, notification);
            }
            catch (Exception)
            {
                System.Diagnostics.Debug.WriteLine("Error handling callback for 'Me' notification");
            }
        }
Exemplo n.º 3
0
        private void GroupCallback(Group group, IBayeuxMessage message)
        {
            var jsonString   = message.Data.ToString();
            var notification = JsonConvert.DeserializeObject <Notifications.Notification>(jsonString);

            Console.WriteLine($"Received {message.Data.ToString()} for {group.Name}");

            try
            {
                var handler = this.NotificationReceived;
                handler?.Invoke(this, notification);
            }
            catch (Exception)
            {
                System.Diagnostics.Debug.WriteLine("Error handling callback for 'Group' notification");
            }
        }
Exemplo n.º 4
0
        private void MessageReceived(User user, Room room, IBayeuxMessage raw)
        {
            // Get the Faya envelope object.
            var envelope = ((JObject)raw.Data).ToObject <Envelope <GitterMessage> >();

            if (envelope.Operation == null || !envelope.Operation.Equals("create", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // From ourselves?
            if (envelope.Model.FromUser?.Id == user.Id)
            {
                return;
            }

            // Create the message representation.
            var message = new Message
            {
                Text = envelope.Model.Text,
                User = new User
                {
                    Id          = envelope.Model.FromUser?.Id,
                    Username    = envelope.Model.FromUser?.Username,
                    DisplayName = envelope.Model.FromUser?.DisplayName
                }
            };

            // Enqueue the message.
            _messageQueue.Enqueue(new MessageEvent(_broker)
            {
                Bot     = user,
                Room    = room,
                Message = message
            });
        }
Exemplo n.º 5
0
 public override bool TryExtendOutgoing(IBayeuxMessage message, out object extension)
 {
     extension = _token;
     return(true);
 }
 public abstract bool TryExtendOutgoing(IBayeuxMessage message, out object extension);