Ejemplo n.º 1
0
 private void mclient_OnMultiCastRX(string cmd)
 {
     if (cmd.StartsWith(HelloVerb.Preamble))
     {
         var verb = new HelloVerb();
         DetectedNode node = verb.ParseRequest(cmd);
         if (null != node)
         {
             DetectedNode search = announcedAddresses.Where(s => s.Address == node.Address).FirstOrDefault();
             if (null == search)
             {
                 node.LastAnnounce = DateTime.Now;
                 announcedAddresses.Add(node);
             }
             else
             {
                 search.LastAnnounce = DateTime.Now;
                 search.OverlordID = node.OverlordID;
                 search.NetworkName = node.NetworkName;
                 search.NetworkID = node.NetworkID;
                 search.Priority = node.Priority;
                 search.CurrentUsers = node.CurrentUsers;
                 search.MaxUsers = node.MaxUsers;
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void processAnnounce(object o)
        {
            while (run)
            {
                var verb = new HelloVerb();

                int maxClients = 0;
                if (model.IsDedicated)
                {
                    maxClients = 100;
                }
                else
                {
                    switch (model.OverlordPriority)
                    {
                        case OverlordPriority.High:
                            maxClients = 100;
                            break;
                        case OverlordPriority.Normal:
                            maxClients = 50;
                            break;
                        case OverlordPriority.Low:
                            maxClients = 40;
                            break;
                    }
                }

                multicastServer.SendMessage(verb.CreateRequest(serverNode.Location, network.NetworkName, serverNode.ID,
                                                               network.NetworkID, serverNode.Strength,
                                                               connectedClientNodes.Count, maxClients));
                announcerSync.WaitOne(10000);
            }
        }