using System; using System.Net; using System.Net.Sockets; namespace Passer.Control.Core { public class SiteServer : Participant { public SiteServer(int port = 7681) { this.ipAddress = "0.0.0.0"; this.port = port; this.endPoint = new IPEndPoint(IPAddress.Parse(ipAddress), 0); // for sending, but should not be used really... this.udpClient = new UdpClient(); // for receiving this.udpClient.Client.Bind(new IPEndPoint(IPAddress.Any, port)); this.udpClient.BeginReceive(new AsyncCallback(result => ReceiveUDP(result)), null); this.name = "Site Server"; } public override void Update(long currentTimeMs) { // for (int ix = 0; ix < this.others.Count; ix++) { // Participant client = this.others[ix]; // if (client == null) // continue; // this.ProcessMessages(client); // } Thing.UpdateAll(currentTimeMs); } protected override void Process(Participant sender, ClientMsg msg) { if (msg.networkId == 0) { Console.WriteLine($"{this.name} received New Client -> {sender.networkId}"); sender.Send(new NetworkIdMsg(sender.networkId)); } } protected override void Process(Participant sender, NetworkIdMsg msg) { } } }