Ejemplo n.º 1
0
 public string Connect(string userName)
 {
     if (!lowClients.ContainsKey(userName))
     {
         clearClientsQueue.CallBounce();
         lowClients.Add(userName, new Queue <string>());
         highClients.Add(userName, new Queue <string>());
         mediumClients.Add(userName, new Queue <string>());
         return(MessageServiceConstants.Success);
     }
     else
     {
         return(MessageServiceConstants.UserNameBusy);
     }
 }
Ejemplo n.º 2
0
        public MessageWorkerService()
        {
            int workerAmount   = int.Parse(ConfigurationManager.AppSettings["workerAmount"]);
            int highPriority   = int.Parse(ConfigurationManager.AppSettings["highPriority"]);
            int mediumPriority = int.Parse(ConfigurationManager.AppSettings["mediumPriority"]);
            int lowPriority    = int.Parse(ConfigurationManager.AppSettings["lowPriority"]);
            int dumpTimeout    = int.Parse(ConfigurationManager.AppSettings["dumpTimeout"]);

            for (int i = 0; i < workerAmount; ++i)
            {
                workers.Add(new MessageWorker(lowPriority, mediumPriority, highPriority));
            }

            clearClientsQueue = new Bounce(() =>
            {
                foreach (var worker in workers)
                {
                    foreach (var userName in lowClients.Keys)
                    {
                        worker.DoJob(lowClients[userName], mediumClients[userName], highClients[userName]);
                    }
                }
            }, dumpTimeout);
            clearClientsQueue.CallBounce();
        }