private void StartServer() { lanBc.StopBroadcasting(); lanBc.StartAnnounceBroadcasting(); udpHandler = new UdpHandler(portGameServer); udpHandler.StartListening(); role = PlayerRole.Server; Debug.Log("Starting Server -> " + udpHandler.SessionId); }
private void ConnectToServer(string ip) { Debug.Log("Connecting to server: " + ip); lanBc.StopBroadcasting(); udpHandler = new UdpHandler(portGameClient); udpHandler.StartListening(); destAddr = new IPEndPoint(IPAddress.Parse(ip), portGameServer); var command = new CommandConnect(); udpHandler.SendMessage(new UdpMessage(destAddr, command)); role = PlayerRole.Client; }
public UdpMessage(IPEndPoint remote, Command cmd, UdpHandler udpHandler = null) { this.remote = remote; this.cmd = cmd; this.udpHandler = udpHandler; }
public UdpMessage(IPEndPoint remote, byte[] data, UdpHandler udpHandler = null) { this.remote = remote; this.cmd = Command.Create(data); this.udpHandler = udpHandler; }