@@ -49,24 +49,26 @@ void UPubnubSubsystem::InitPubnub()
49
49
PubnubError (" Pubnub is already initialized" , EPubnubErrorType::PET_Warning);
50
50
return ;
51
51
}
52
-
53
- // Create new threads - separate for subscribe and all other operations
54
- QuickActionThread = new FPubnubFunctionThread;
55
- LongpollThread = new FPubnubLoopingThread;
56
-
57
- if (!CheckQuickActionThreadValidity ())
58
- {return ;}
59
52
60
- QuickActionThread->AddFunctionToQueue ( [this ]
53
+ InitPubnub_priv ();
54
+
55
+ // If initialized correctly, create required thread.
56
+ if (IsInitialized)
61
57
{
62
- InitPubnub_priv ();
63
- });
58
+ // Create new threads - separate for subscribe and all other operations
59
+ QuickActionThread = new FPubnubFunctionThread;
60
+ LongpollThread = new FPubnubLoopingThread;
61
+ }
62
+
64
63
}
65
64
66
65
void UPubnubSubsystem::DeinitPubnub ()
67
66
{
68
- if (!CheckQuickActionThreadValidity ())
69
- {return ;}
67
+ if (!QuickActionThread)
68
+ {
69
+ DeinitPubnub_priv ();
70
+ return ;
71
+ }
70
72
71
73
QuickActionThread->AddFunctionToQueue ( [this ]
72
74
{
@@ -828,6 +830,11 @@ void UPubnubSubsystem::PubnubError(FString ErrorMessage, EPubnubErrorType ErrorT
828
830
UE_LOG (PubnubLog, Warning, TEXT (" %s" ), *ErrorMessage);
829
831
}
830
832
833
+ if (!OnPubnubError.IsBound ())
834
+ {
835
+ return ;
836
+ }
837
+
831
838
// Errors has to be broadcasted on GameThread, otherwise engine will crash if someone uses them for example with widgets
832
839
AsyncTask (ENamedThreads::GameThread, [this , ErrorMessage, ErrorType]()
833
840
{
@@ -959,11 +966,13 @@ void UPubnubSubsystem::InitPubnub_priv()
959
966
if (std::strlen (PublishKey) == 0 )
960
967
{
961
968
PubnubError (" Publish key is empty, can't initialize Pubnub" );
969
+ return ;
962
970
}
963
971
964
972
if (std::strlen (SubscribeKey) == 0 )
965
973
{
966
974
PubnubError (" Subscribe key is empty, can't initialize Pubnub" );
975
+ return ;
967
976
}
968
977
969
978
ctx_pub = pubnub_alloc ();
@@ -1179,8 +1188,11 @@ void UPubnubSubsystem::UnsubscribeFromAll_priv()
1179
1188
}
1180
1189
1181
1190
LongpollThread->ClearLoopingFunctions ();
1182
-
1183
- SystemPublish (ChannelForSystemPublish);
1191
+
1192
+ if (!ChannelForSystemPublish.IsEmpty ())
1193
+ {
1194
+ SystemPublish (ChannelForSystemPublish);
1195
+ }
1184
1196
}
1185
1197
1186
1198
void UPubnubSubsystem::AddChannelToGroup_priv (FString ChannelName, FString ChannelGroup)
0 commit comments