Exemplo n.º 1
0
        void c_Connected(object sender, ConnectedEventArgs e)
        {
            //todo: send game data to client (c.send)
            if (e.Succes)
            {
                Client c = ((Client)sender);
                ((Client)sender).Connected -= c_Connected;
                Console.WriteLine(c.Send("connection succes:"+(Clients.IndexOf(c)+1).ToString()));
                Console.WriteLine("sending");

            }
        }
Exemplo n.º 2
0
 void c_Connected(object sender, ConnectedEventArgs e)
 {
     Client c = (Client)sender;
     c.Send("myid:"+this.ID.ToString());
     if (c.DataAvailable)
     {
         string s = c.RecieveString();
         if (s.Contains("myid"))
         {
             c.ID = int.Parse(s.Split(':')[1]);
         }
     }
     if (DataRevieved!=null)
         DataRevieved(this, new NewDataEventArgs() { Data = "id " + c.ID.ToString() + " connected" });
 }