public override void _Process(float delta) { if (connected && !client.IsConnectedToHost()) { connected = false; disconnected = true; } if (connected) { getPackets(); } if (disconnected) { GD.Print(String.Format("Reconnecting to {0}:{1}", ip, port)); client.ConnectToHost(ip, port); if (client.IsConnectedToHost()) { client.SetNoDelay(true); client.SetBlockSignals(true); wrapped_client = new PacketPeerStream(); wrapped_client.SetStreamPeer(client); connected = true; disconnected = false; GD.Print("Reconnected."); } else { GD.Print("Failed to connect."); } } }
public void start() { GD.Print(String.Format("Connecting to {0}:{1}", ip, port)); client.ConnectToHost(ip, port); if (client.IsConnectedToHost()) { client.SetNoDelay(true); client.SetBlockSignals(true); wrapped_client = new PacketPeerStream(); wrapped_client.SetStreamPeer(client); var testPacket = new Packets.PingPacket("Hello There!"); //sendPacket(testPacket); //GD.Print(client.PutData(data)); connected = true; GD.Print("Connected."); } else { GD.Print("Failed to connect."); } }