客户端.h
需要在Build.cs中加入模块:"Networking","Sockets","Json","JsonUtilities"
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ClientActorClass.generated.h"
UCLASS()
class TCPSERVERANDCLIENT_API AClientActorClass : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AClientActorClass();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
static FSocket* Socket;
//"Networking","Sockets"
UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
static bool ClientConnectToTCPServer(const FString& IP,int32 Port = 8888);
UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
static bool SendDataFormClicentToServer(TArray<uint8> SendData);
UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
static bool DisConnectFormClientToServer();
UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
static TArray<uint8> ReceiveDataFromTCPServer();
//"Json","JsonUtilities"
UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
static void StringToBytes(FString InString,bool& OutBool,TArray<uint8>& OutBytesArray);
UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
static void DataTypeToJSON(int32 Int,bool Inbool,F