示例#1
0
文件: Treatment.cs 项目: fiahil/Zappy
 public void Initialize(Main p)
 {
     parent = p;
     tab = new Dictionary<string, TreatCmd>();
     tab["msz"] = msz;
     tab["bct"] = bct;
     tab["tna"] = tna;
     tab["pnw"] = pnw;
     tab["ppo"] = ppo;
     tab["plv"] = plv;
     tab["pin"] = pin;
     tab["pex"] = pex;
     tab["pbc"] = pbc;
     tab["pic"] = pic;
     tab["pie"] = pie;
     tab["pfk"] = pfk;
     tab["pdr"] = pdr;
     tab["pgt"] = pgt;
     tab["pdi"] = pdi;
     tab["enw"] = enw;
     tab["eht"] = eht;
     tab["ebo"] = ebo;
     tab["edi"] = edi;
     tab["sgt"] = sgt;
     tab["seg"] = seg;
     tab["smg"] = smg;
     tab["suc"] = suc;
     tab["sbp"] = sbp;
 }
示例#2
0
文件: Network.cs 项目: fiahil/Zappy
        public void Initialize(Main p)
        {
            Popup pop = new Popup();
            Byte[] buff = new byte[128];
            _out = new Queue<string>();
            _in = new Queue<string>();
            t = new Treatment();

            t.Initialize(p);
            pop.ShowDialog();
            if (pop.isValid())
            {
                try
                {
                    IPAddress[] IPs = Dns.GetHostAddresses(pop.GetIp());

                    s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    s.Connect(IPs[0], pop.GetPort());
                }
                catch (SocketException e)
                {
                    Console.WriteLine("Error on Socket\nWhat: {0}", e.Message);
                    MessageBox.Show(e.Message, "Connection failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                    connected = false;
                    return;
                }
                catch (FormatException e)
                {
                    MessageBox.Show(e.Message, "Invalid port.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                    connected = false;
                    return;
                }

                if (s.Poll(60000000, SelectMode.SelectRead))
                {
                    connected = true;
                    s.Receive(buff);
                }
                else
                {
                    MessageBox.Show("Connection impossible with the server.", "Connection timeout.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    connected = true;
                    return;
                }
                if (Encoding.UTF8.GetString(buff).CompareTo("BIENVENUE\n") == 0)
                {
                    s.Send(Encoding.UTF8.GetBytes("GRAPHIC\n"));
                }
            }
            else
            {
                connected = false;
            }
        }
示例#3
0
文件: Program.cs 项目: fiahil/Zappy
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Main game = new Main())
     {
         try
         {
             game.Run();
         }
         catch { }
     }
 }