Пример #1
0
        public Producer(ProducerSetting setting = null, string name = null)
        {
            Name = name;
            Setting = setting ?? new ProducerSetting();

            if (Setting.NameServerList == null || Setting.NameServerList.Count() == 0)
            {
                throw new Exception("Name server address is not specified.");
            }

            _queueSelector = ObjectContainer.Resolve<IQueueSelector>();
            _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName);

            var clientSetting = new ClientSetting
            {
                ClientName = Name,
                ClusterName = Setting.ClusterName,
                NameServerList = Setting.NameServerList,
                SocketSetting = Setting.SocketSetting,
                OnlyFindMasterBroker = true,
                SendHeartbeatInterval = Setting.HeartbeatBrokerInterval,
                RefreshBrokerAndTopicRouteInfoInterval = Setting.RefreshBrokerAndTopicRouteInfoInterval
            };
            _clientService = new ClientService(clientSetting, this, null);
        }
Пример #2
0
        public Consumer(string groupName, ConsumerSetting setting, string consumerName = null)
        {
            if (groupName == null)
            {
                throw new ArgumentNullException("groupName");
            }

            Name = consumerName;
            GroupName = groupName;
            Setting = setting ?? new ConsumerSetting();

            if (Setting.NameServerList == null || Setting.NameServerList.Count() == 0)
            {
                throw new Exception("Name server address is not specified.");
            }

            _subscriptionTopics = new Dictionary<string, HashSet<string>>();
            _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>();
            _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName);

            var clientSetting = new ClientSetting
            {
                ClientName = Name,
                ClusterName = Setting.ClusterName,
                NameServerList = Setting.NameServerList,
                SocketSetting = Setting.SocketSetting,
                OnlyFindMasterBroker = true,
                SendHeartbeatInterval = Setting.HeartbeatBrokerInterval,
                RefreshBrokerAndTopicRouteInfoInterval = Setting.RefreshBrokerAndTopicRouteInfoInterval
            };
            _clientService = new ClientService(clientSetting, null, this);
            _pullMessageService = new PullMessageService(this, _clientService);
            _commitConsumeOffsetService = new CommitConsumeOffsetService(this, _clientService);
            _rebalanceService = new RebalanceService(this, _clientService, _pullMessageService, _commitConsumeOffsetService);
        }
        public SuperSocketSocketClient(ILogger <SuperSocketSocketClient> logger, IFluentSocketApplication app, ISocketSessionBuilder socketSessionBuilder, ClientSetting setting)
        {
            _logger = logger;
            _app    = app;
            _socketSessionBuilder = socketSessionBuilder;

            _setting = setting;
            if (!_setting.ExtraSettings.Any())
            {
                _setting.ExtraSettings.Add(new SuperSocketClientSetting());
            }
            _extraSetting = (SuperSocketClientSetting)_setting.ExtraSettings.FirstOrDefault();

            _cts = new CancellationTokenSource();

            _semaphoreSlim          = new SemaphoreSlim(1);
            _manualResetEventSlim   = new ManualResetEventSlim(true);
            _reqPushChannel         = SystemChannel.CreateBounded <PushReqPacket>(_setting.PushReqCapacity);
            _pushMessageHandlerDict = new ConcurrentDictionary <short, IPushMessageHandler>();
            _responseFutureDict     = new ConcurrentDictionary <int, ResponseFuture>();
        }
Пример #4
0
 public ReConnectHandler(ILogger <ReConnectHandler> logger, ClientSetting setting, Func <Task> reConnectAction)
 {
     _logger          = logger;
     _setting         = setting;
     _reConnectAction = reConnectAction;
 }
Пример #5
0
 public static ClientSetting AddDotNettySetting(this ClientSetting setting, DotNettyClientSetting extraSetting)
 {
     setting.ExtraSettings.Add(extraSetting);
     return(setting);
 }
 public CustomerMatchController(IOptions <GraphSetting> graphSetting, IOptions <ClientSetting> clientSetting)
 {
     _graphSetting  = graphSetting.Options;
     _clientSetting = clientSetting.Options;
 }
Пример #7
0
        //Send email to invitees when they are invited to a reservation
        public void EmailOnInvited(int reservationId, IEnumerable <Invitee> invitees, int clientId, ReservationModificationType modificationType = ReservationModificationType.Created)
        {
            if (invitees == null)
            {
                return;
            }

            var invited = invitees.Where(x => !x.Removed).ToArray();

            if (invited.Length == 0)
            {
                return;
            }

            var           rsv = Require <ReservationInfo>(reservationId);
            string        fromAddr, subject, body;
            List <string> toAddr = new List <string>();

            fromAddr = Properties.Current.SchedulerEmail;
            subject  = $"{SendEmail.CompanyName} - Reservation Invitation";

            //reservationType
            string invitedModifiedText;

            if (modificationType == ReservationModificationType.Created)
            {
                invitedModifiedText = "invited you to a reservation";
            }
            else
            {
                invitedModifiedText = "modified a reservation to which you are invited";
            }

            body  = string.Format("{0} has {1} for resource {2}.", Clients.GetDisplayName(rsv.LName, rsv.FName), invitedModifiedText, rsv.ResourceName);
            body += Environment.NewLine + string.Format("- Begin time: {0}", rsv.BeginDateTime.ToString(Reservation.DateFormat));
            body += Environment.NewLine + string.Format("- End time: {0}", rsv.EndDateTime.ToString(Reservation.DateFormat));

            foreach (var ri in invited)
            {
                //Send email if invitee wants to receive email
                ClientSetting inviteeSetting = Session.Get <ClientSetting>(ri.InviteeID);
                if (inviteeSetting != null)
                {
                    if (inviteeSetting.EmailInvited.Value)
                    {
                        var primary = Client.GetPrimary(ri.InviteeID);
                        if (primary != null)
                        {
                            toAddr.Add(primary.Email);
                        }
                    }
                }
            }

            if (toAddr.Count == 0)
            {
                return;
            }

            SendEmail.Send(clientId, "LNF.Scheduler.EmailUtility.EmailOnInvited", subject, body, fromAddr, toAddr);
        }