// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "WebSocketManager.generated.h"

DECLARE_MULTICAST_DELEGATE_OneParam(FOnConnectDelegate, bool);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnDataReceiveDelaget, TArray<FString>);
/**
 * 
 */
UCLASS()
class AIGC_API UWebSocketManager : public UObject
{
	GENERATED_BODY()
public:
	void InitWebSocket(const FString& ServerIP);
	void SendData(const FString& Data);
	UFUNCTION()
	void HandleConnected();
	UFUNCTION()
	void HandleClosed(const int32& Code, const FString& Reason, bool bClosedByPeer);
	UFUNCTION()
	void HandleConnectionError(const FString& ErrorReason);
	UFUNCTION()
	void HandleOnMessageSend(const FString& Message);
	UFUNCTION()
	void HandleOnReceiveText(const FString& Message);
	
public:
	FOnConnectDelegate OnConnectDelegate;
	FOnDataReceiveDelaget OnDataReceiveDelaget;
private:
	UPROPERTY()
	class UWebSocketHandler* WebSocketHandler;
};
