Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
getnamo committed May 7, 2017
2 parents cbe9351 + f11d9e3 commit d7b3d81
Show file tree
Hide file tree
Showing 16 changed files with 743 additions and 275 deletions.
2 changes: 1 addition & 1 deletion SocketIOClient.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "0.5.4",
"VersionName": "0.6.0",
"FriendlyName": "Socket.IO Client",
"Description": "Real-time networking library Socket.IO Client usable from blueprints and c++.",
"Category": "Networking",
Expand Down
2 changes: 1 addition & 1 deletion Source/SIOJson/Private/SIOJConvert.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "SIOJsonPrivatePCH.h"

Expand Down
2 changes: 1 addition & 1 deletion Source/SIOJson/Public/SIOJConvert.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.


#pragma once

Expand Down
3 changes: 1 addition & 2 deletions Source/SocketIOClient/Private/SIOLambdaRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ uint32 FSIOLambdaRunnable::Run()
{
FunctionPointer();
}
UE_LOG(LogClass, Log, TEXT("FLambdaRunnable %d Run complete"), Number);
//UE_LOG(LogClass, Log, TEXT("FLambdaRunnable %d Run complete"), Number);
return 0;
}

Expand All @@ -56,7 +56,6 @@ void FSIOLambdaRunnable::Stop()

void FSIOLambdaRunnable::Kill()
{
UE_LOG(LogClass, Log, TEXT("Yolo!"));
Thread->Kill(false);
Finished = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/SocketIOClient/Private/SIOMessageConvert.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "SocketIOClientPrivatePCH.h"

Expand Down
65 changes: 62 additions & 3 deletions Source/SocketIOClient/Private/SocketIOClient.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,79 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "SocketIOClientPrivatePCH.h"
#include "SocketIONative.h"
#include "SIOLambdaRunnable.h"

#define LOCTEXT_NAMESPACE "FSocketIOClientModule"

class FSocketIOClientModule : public ISocketIOClientModule
{
public:
virtual FSocketIONative* NewValidNativePointer() override;
void ReleaseNativePointer(FSocketIONative* PointerToRelease) override;

/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;

private:
FCriticalSection DeleteSection;
TArray<FSocketIONative*> ModulePointers;
};

#define LOCTEXT_NAMESPACE "FSocketIOClientModule"

void FSocketIOClientModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module

ModulePointers.Empty();
}

void FSocketIOClientModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
FScopeLock Lock(&DeleteSection);

ModulePointers.Empty();

/*for (auto& Pointer : ModulePointers)
{
if (Pointer)
{
delete Pointer;
Pointer = nullptr;
}
}*/
}

FSocketIONative* FSocketIOClientModule::NewValidNativePointer()
{
FSocketIONative* NewPointer = new FSocketIONative;
ModulePointers.Add(NewPointer);

return NewPointer;
}

void FSocketIOClientModule::ReleaseNativePointer(FSocketIONative* PointerToRelease)
{
PointerToRelease->OnConnectedCallback = [PointerToRelease](const FString& SessionId)
{
//If we're still connected, disconnect us
if (PointerToRelease)
{
PointerToRelease->SyncDisconnect();
}
};

//Release the pointer on the background thread
FSIOLambdaRunnable::RunLambdaOnBackGroundThread([PointerToRelease, this]
{
FScopeLock Lock(&DeleteSection);

if (PointerToRelease)
{
delete PointerToRelease;
}
});
}

#undef LOCTEXT_NAMESPACE
Expand Down
Loading

0 comments on commit d7b3d81

Please sign in to comment.