Ejemplo n.º 1
0
        public void PublishMessageReceived(PublishPacketReceivedEventArgs message)
        {
            if (_jsonConfigurator.GetSettings().RunInClusterSetup)
            {
                if (!_publishers.Any(x => x.Ip == message.IpAddress && x.Port == message.Port))
                {
                    lock (_harakaDb.GetLock(Setup.PublisherCs))
                    {
                        var pubs      = _harakaDb.GetObjects <Publisher>(Setup.PublisherCs);
                        var publisher = new Publisher(message.IpAddress, message.Port, _jsonConfigurator.GetSettings().PrimaryNumber, message.SenderClient);
                        pubs.Add(publisher);
                        _harakaDb.StoreObject(Setup.PublisherCs, pubs);
                        _publishers.Add(publisher);
                    }
                }

                _queues.Find(x => x.GetTopicId() == message.Packet.Topic).AddEvent(new Event(message, EventType.TentativeMessage));
                lock (_messagesLock)
                {
                    OwnTentativeMessages.Add(message);
                }
            }
            else
            {
                _queues.Find(x => x.GetTopicId() == message.Packet.Topic).AddEvent(new Event(message, EventType.ComittedMessage));
                lock (_messagesLock)
                {
                    CommittedMessages.Add(message);
                }
            }
        }
Ejemplo n.º 2
0
 private void UpdateIngoingSequence(string clientId, int msgSeqNo)
 {
     lock (_harakaDb.GetLock(Setup.ClientsCS))
     {
         var clients = _harakaDb.GetObjects <Client>(Setup.ClientsCS);
         var client  = clients.Find(x => x.Id == clientId);
         client.SetIngoingSeqNo(msgSeqNo);
         _harakaDb.StoreObject(Setup.ClientsCS, clients);
     }
 }
Ejemplo n.º 3
0
        public void Send(ExtendedPacketInformation msg)
        {
            var sendMsg = new SenderMessage
            {
                Body = MessagePackSerializer.Serialize(msg.Packet),
                Type = msg.UdpMessageType
            };

            lock (_harakaDb.GetLock(Setup.OutgoingMessagesCS))
            {
                var messages = _harakaDb.GetObjects <ExtendedPacketInformation>(Setup.OutgoingMessagesCS);
                messages.Add(msg);
                _harakaDb.StoreObject(Setup.OutgoingMessagesCS, messages);
            }

            _sender.SendMsg(sendMsg, msg.Ip, msg.Port);
        }
Ejemplo n.º 4
0
 public void AddEvent(Topic topic, Event @event)
 {
     lock (_db.GetLock(_fileName))
     {
         var topics = _db.GetObjects <Topic>(_fileName);
         topics.Find(x => x.Id == topic.Id).Events.Add(@event);
         _db.StoreObject(_fileName, topics);
     }
     EventAddedToQueue();
 }