Unreal SDK  v1.1
Loading...
Searching...
No Matches
WeArtController.h
Go to the documentation of this file.
1#pragma once
2
3#include "CoreMinimal.h"
4#include "Sockets.h"
8#include "GameFramework/Actor.h"
9#include "Kismet/GameplayStatics.h"
10#include <string>
11
12#include "WeArtController.generated.h"
13
15{
17};
18
20{
22};
23
24static char messagesSeparator = '~';
25
29UCLASS()
30class WEARTPLUGIN_API UWeArtController : public UGameInstanceSubsystem
31{
32 GENERATED_BODY()
33
34public:
35
38
40
41 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
42 virtual void Deinitialize() override;
43
44 UFUNCTION(BlueprintCallable)
45 void PauseController();
46 UFUNCTION(BlueprintCallable)
47 void UnpauseController();
48 UFUNCTION(BlueprintCallable)
49 void StartCalibration();
50 UFUNCTION(BlueprintCallable)
51 void StopCalibration();
52
53 void ScheduleController();
54
55 void SendMessage(WeArtMessage* message);
56 bool ReceiveMessages(std::vector<WeArtMessage*>& messages);
57
58 void OnMessageReceived(WeArtMessage* msg);
59 void StopConnection();
60
61 void LogMessage(WeArtMessageType type, FString& message);
62 void LogError(WeArtError error, FString& message);
63
64 void HandleReceivedMessage(FString& message);
65 // We are keeping track of attached thimble tracking objects,
66 // so we can forward received messages to them. Usually
67 // that could be solved via delegates, but native C++
68 // has no support for those, and UE4 delegates would require
69 // the WeArtMessage object to be an UCLASS for some reason.
70 TArray<UWeArtThimbleTrackingObject*> thimbleTrackingObjects;
71
72protected:
73
74 UPROPERTY()
75 int ClientPort;
76
77 UPROPERTY()
78 bool DebugMessages;
79
80 UPROPERTY()
81 bool ControllerAutoStart;
82
83 UPROPERTY()
84 bool CalibrationAutoStart;
85
86 bool foundTrackingCalibration = false;
87 bool isCancellationRequested = false;
88 FSocket* socket;
89 WeArtMessageSerializer messageSerializer;
90 uint8* messageReceivedBuffer[1024];
91 std::string trailingText;
92 bool IsConnected = false;
93 bool IsPaused = false;
94};
WeArtError
Definition: WeArtController.h:20
@ ConnectionError
Definition: WeArtController.h:21
@ SendMessageError
Definition: WeArtController.h:21
@ ReceiveMessageError
Definition: WeArtController.h:21
WeArtMessageType
Definition: WeArtController.h:15
@ MessageReceived
Definition: WeArtController.h:16
@ MessageSent
Definition: WeArtController.h:16
Calibration status/result observer.
Definition: WeArtTrackingCalibration.h:21
Weart controller, used to connect to the Weart middleware, perform operations and receive messages.
Definition: WeArtController.h:31
AWeArtTrackingCalibration * TrackingCalibration
Definition: WeArtController.h:39
TArray< UWeArtThimbleTrackingObject * > thimbleTrackingObjects
Definition: WeArtController.h:70
Generic Weart message.
Definition: WeArtMessages.h:94
Serializer for communication with the middleware.
Definition: WeArtMessageSerializer.h:10