예제 #1
0
파일: Form1.cs 프로젝트: kuhjunge/maedn
 // -- Netzwerk starten --
 private void buttonNetServer_Click(object sender, EventArgs e)
 {
     srv = new Server();
     srv.UpdateText += UpdateLabelText; // Ereignis abonnieren
     if (radioButtonNetTCP.Checked)
     {
         if (checkBoxIPv6.Checked) srv.connect("v6", numericUpDownNetPort.Value.ToString());
         else srv.connect("v4", numericUpDownNetPort.Value.ToString());
         numericUpDownKISpeed.Value = 500;
         numericUpDownKISpeed.Minimum = 500;
     }
     else
     {
         if (checkBoxIPv6.Checked) srv.connect("udpv6", numericUpDownNetPort.Value.ToString());
         else srv.connect("udp", numericUpDownNetPort.Value.ToString());
     }
     txtbx("Server Online");
     labelNetStatus.Text = "Sie sind verbunden!";
     MessageBox.Show("Der Server wurde erfolgreich geöffnet!",
                     "Über Mensch Ärgere Dich nicht", MessageBoxButtons.OK, MessageBoxIcon.Information);
     buttonCommand.Enabled = false;
     groupBoxNetwork.Enabled = false;
     srv.online();
     buttonDebug.Visible = true;
     buttonDebug.Text = "Server beenden";
     groupBoxNetwork.Size = new Size(206, 115);
     textBoxNetIP.Text = Server.GetLocalAddresses("")[0];
 }
예제 #2
0
파일: Form1.cs 프로젝트: kuhjunge/maedn
 // netzwerk scannen (broadcast)
 private void buttonNetScan_Click(object sender, EventArgs e)
 {
     byte[] byteBuffer = System.Text.Encoding.ASCII.GetBytes("hello Server");
     if (broadcast == null)
     {
         broadcast = new Server();
         if (checkBoxIPv6.Checked) broadcast.connect("udpv6", "7");
         else broadcast.connect("udp", "7");
         broadcast.UpdateText += broadcastincomming; // Ereignis abonnieren
     }
     listBoxNetServer.Items.Clear();
     broadcast.BroadCastSend(byteBuffer, 7);
 }
예제 #3
0
파일: Form1.cs 프로젝트: kuhjunge/maedn
        // -- Ereignis vom Server auslösen --
        void broadcastincomming(object sender, Server.TextEventArgs e)
        {
            if (listBoxNetServer.InvokeRequired)
            {
                listBoxNetServer.Invoke(new MethodInvoker(delegate
                {
                    string HostName = System.Net.Dns.GetHostName();

                    string[] strarr = e.Text.Split(':');
                    if (strarr[0] != Server.GetLocalAddresses("")[3])
                    {
                        listBoxNetServer.Items.Add(strarr[0]);
                        txtbx(strarr[0] + " " + Server.GetLocalAddresses("")[3]);
                    }
                }));
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: kuhjunge/maedn
 private void buttonDebug_Click(object sender, EventArgs e)
 {
     try
     {
         if (clt != null)
         {
             clt.send("end:");
             clt.disconnect();
             buttonLoad.Enabled = true;
             clt = null;
         }
         if (srv != null)
         {
             srv.send("end:");
             srv.close();
             srv = null;
         }
         if (broadcast != null) broadcast.close();
     }
     catch { } //(Exception se) { MessageBox.Show(se.Message); }
     txtbx("Netzwerk getrennt");
     labelNetStatus.Text = "Netzwerk getrennt!";
     buttonCommand.Enabled = true;
     groupBoxNetwork.Enabled = true;
     updatefiguren("Mensch", "Computer", "", "");
     buttonCommand.Text = "Spiel starten";
     buttonDebug.Visible = false;
     groupBoxNetwork.Size = new Size(206, 188);
     buttonNeuesSpiel.Enabled = true;
 }
예제 #5
0
파일: Form1.cs 프로젝트: kuhjunge/maedn
 void UpdateLabelText(object sender, Server.TextEventArgs e)
 {
     if (e.Text.StartsWith("?"))
     {
         srv.send("Server: " + textBoxNetName.Text);
     }
     // TExt ausgabe
     else if (e.Text.Length > 2)
         txtbx("Net: " + e.Text + " \r\n");
     else txtbx(e.Text);
 }