예제 #1
0
        //check exists connection name in combobox
        static bool IsExistsConnectionName(string NewConnName)
        {
            List <ConnectionBase> ConnList;

            try
            {
                ConnList = Common.ConnectionStrings.LoadConnectionStrings();//deserialize list of connection from file
            }
            catch
            {
                return(false);
            }
            var matches = ConnList.Where(p => p.ConnName == NewConnName);

            if (matches.Count() > 0)
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
 //FUNCTION:
 //Purpose: To get the data sent by the server and to translate it into a command
 public void GetData(byte[] data, string iD)
 {
     string msg = ASCIIEncoding.ASCII.GetString(data);
     if (msg.StartsWith("POINTUS::")) //Our team scores a point
     {
         string msgs = msg.Replace("POINTUS::", "");
         if (msgs.StartsWith("+"))
         {
             OurPoints++;
         }
         if (msgs.StartsWith("-"))
         {
             OurPoints--;
         }
     }
     if (msg.StartsWith("POINTTHEM::")) //Other team scores a point
     {
         string msgs = msg.Replace("POINTTHEM::", "");
         if (msgs.StartsWith("+"))
         {
             TheirPoints++;
         }
         if (msgs.StartsWith("-"))
         {
             TheirPoints--;
         }
     }
     if (msg.StartsWith("MSG::")) //Text message from server
     {
         string msgs = msg.Replace("MSG::", "");
         ServerMsg = msgs;
     }
     if (msg.StartsWith("NT::")) //Name taken (not currently in use)
     {
         string msgs = msg.Replace("NT::", "");
         NameTaken = true;
     }
     if (msg.StartsWith("TEAMADD::")) //Team member joined
     {
         string msgs = msg.Replace("TEAMADD::", "");
         HomeList.Add(msgs);
     }
     if (msg.StartsWith("OPPADD::")) //Opponent team member joined
     {
         string msgs = msg.Replace("OPPADD::", "");
         AwayList.Add(msgs);
     }
     if (msg.StartsWith("ROUNDSTART::")) //Round has started
     {
         string msgs = msg.Replace("ROUNDSTART::", "");
         StartRound(msgs);
     }
     if (msg.StartsWith("ROUNDSTOP::")) //Round has stopped
     {
         string msgs = msg.Replace("ROUNDEND::", "");
         StopRound();
     }
     if (msg.StartsWith("TEAMFULL::")) //Team selected is full
     {
         string msgs = msg.Replace("TF::", "");
         TeamFull = true;
     }
     if (msg.StartsWith("TEAMOPT::")) //List of team options
     {
         string msgs = msg.Replace("TEAMOPT::", "");
         TeamOptions = msgs.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries).ToList();
     }
     if (msg.StartsWith("TEAMLIST::")) //List of team members at join
     {
         string msgs = msg.Replace("TEAMLIST::", "");
         HomeList = msgs.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries).ToList();
     }
     if (msg.StartsWith("OPPLIST::")) //List of opponent team members at join
     {
         string msgs = msg.Replace("OPPLIST::", "");
         AwayList = msgs.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries).ToList();
     }
     if (msg.StartsWith("CLIST::")) //Hidden client list
     {
         string msgs = msg.Replace("CLIST::", "");
         ConnList = msgs.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries).ToList();
     }
     if (msg.StartsWith("DISCONNECT::")) //Client has disconnected
     {
         string msgs = msg.Replace("DISCONNECT::", "");
         if (HomeList.Contains(msgs)) { HomeList.Remove(msgs); }
         if (AwayList.Contains(msgs)) { AwayList.Remove(msgs); }
         ConnList.Remove(msgs);
     }
     if (msg.StartsWith("CONNECT::")) //Client has connected
     {
         string msgs = msg.Replace("CONNECT::", "");
         ConnList.Add(msgs);
     }
     if (msg.StartsWith("PING::")) //Ping (not in use)
     {
         string msgs = msg.Replace("PING::", "");
         IsConnected = true;
     }
 }