using Godot;
using Microsoft.Win32;
using System.Net;
using System.Net.Sockets;
using System.Text;
public partial class ClientUDP : Node
{
private UdpClient client = new UdpClient();
private IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse("192.168.0.135"), 1738);
private IPEndPoint receiveEndPoint = new IPEndPoint(IPAddress.Any, 0);
public override void _Ready()
{
// Send data to the server
byte[] data = Encoding.UTF8.GetBytes("UDP client connected");
client.Send(data, data.Length, remoteEndPoint);
client.Flush();
}
public override void _Process(double delta)
{
byte[] receivedData = client.Receive(ref receiveEndPoint);
string response = Encoding.UTF8.GetString(receivedData);
GD.Print("THIRD PART WORKS"); //
// Listen for packets
if (response == "RK")
{
GD.Print("RK WORKS!!!!");
}
else if (response == "LK")
{
GD.Print("LK WORKS!!!!");
}
else if (response == "RP")
{
GD.Print("RP WORKS!!!!");
}
}
}