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 static void Update() { if (socket == null || socket.IsConnectedToHost() == false) { return; } Recv(); }
public override void _Process(float delta) { if (!client.IsConnectedToHost()) { SetProcess(false); return; } // read incoming packet while (client.GetAvailableBytes() > 0) { // read len int len = dataTypes.ReadNextVarIntFromStream(client); if (len == 0) { GD.Print("Got zero length packet"); } else { handlePacket(readPacketInternal(len)); } } // send queued packets while (packetQueue.Count > 0) { sendPacketInternal(packetQueue.Dequeue()); } }