-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebsocketSampleSubsystem.h
40 lines (30 loc) · 1.05 KB
/
WebsocketSampleSubsystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Subsystems/GameInstanceSubsystem.h"
#include "WebsocketSampleSubsystem.generated.h"
class IWebSocket;
DECLARE_LOG_CATEGORY_EXTERN(LogMyWebSocket, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSockMsg, FString, msg);
/**
*
*/
UCLASS()
class WEBSOCK_SAMPLE_API UWebsocketSampleSubsystem : public UGameInstanceSubsystem
{
GENERATED_BODY()
public:
virtual void Initialize(FSubsystemCollectionBase& Collection)override;
virtual void Deinitialize()override;
UFUNCTION(BlueprintPure)
FString CurrentMessage()const;
UPROPERTY(BlueprintAssignable)
FSockMsg OnReceiveSockMsg;
private:
void OnSocketConnected()const;
void OnSocketConnectioinError(const FString& err)const;
void OnSocketClosed(const int statusCode, const FString& reason, const bool wasClean)const;
void OnSocketMessageReceived(const FString& msg);
TSharedPtr<IWebSocket> Socket = nullptr;
FString currentMsg;
};