Commit 3d6c86e1 by wester
parents 31d00b45 f09ab485
...@@ -27,7 +27,7 @@ public class MasterTestProject : ModuleRules ...@@ -27,7 +27,7 @@ public class MasterTestProject : ModuleRules
PrivateDependencyModuleNames.AddRange(new string[] { }); PrivateDependencyModuleNames.AddRange(new string[] { });
LoadAssimp(Target); LoadAssimp(Target);
LoadAMQP(Target); //LoadAMQP(Target);
// Uncomment if you are using Slate UI // Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "RabbitMQConnection.h"
#include "MyGameInstance.generated.h" #include "MyGameInstance.generated.h"
/** /**
...@@ -16,7 +15,6 @@ class MASTERTESTPROJECT_API UMyGameInstance : public UGameInstance ...@@ -16,7 +15,6 @@ class MASTERTESTPROJECT_API UMyGameInstance : public UGameInstance
GENERATED_BODY() GENERATED_BODY()
public: public:
URabbitMQConnection* connection = nullptr;
......
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include "RabbitMQConnection.h"
URabbitMQConnection::URabbitMQConnection(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
char const *hostname = "10.1.7.49";
int port = 5672;
conn = amqp_new_connection();
socket = amqp_tcp_socket_new(conn);
if (!socket) {
UE_LOG(TILES, Error, TEXT("No RabbitMQ Socket"));
}
int status = amqp_socket_open(socket, hostname, port);
if (status) {
UE_LOG(TILES, Error, TEXT("Cann not Open Socket"));
}
amqp_rpc_reply_t returncode = amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest");
if (AMQP_RESPONSE_NORMAL != returncode.reply_type) {
UE_LOG(TILES, Error, TEXT("Unable to Login"));
}
amqp_channel_open(conn, 1);
returncode = amqp_get_rpc_reply(conn);
if (AMQP_RESPONSE_NORMAL != returncode.reply_type) {
UE_LOG(TILES, Error, TEXT("Opening channel error"));
}
success = true;
}
URabbitMQConnection::~URabbitMQConnection()
{
if (!success) {
return;
}
amqp_rpc_reply_t returncode = amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS);
if (AMQP_RESPONSE_NORMAL != returncode.reply_type) {
UE_LOG(TILES, Error, TEXT("Closing channel error"));
}
returncode = amqp_connection_close(conn, AMQP_REPLY_SUCCESS);
if (AMQP_RESPONSE_NORMAL != returncode.reply_type) {
UE_LOG(TILES, Error, TEXT("Closing connection error"));
}
int errorcode = amqp_destroy_connection(conn);
if (errorcode != 0) {
UE_LOG(TILES, Error, TEXT("Ending AMQP error"));
}
}
bool URabbitMQConnection::publishMessage(char const * Message)
{
if (!success){
UE_LOG(TILES, Warning, TEXT("Cant send Messsage, no Connection"));
return false;
}
char const *exchange = "";
char const *routingkey = "to_hololense";
// char const *messagebody = "{\"timestamp\":15.600000381469727,\"start\":{\"x\":0.0,\"y\":0.0,\"z\":0.0},\"end\":{\"x\":1.0,\"y\":5.0,\"z\":16.0}}";
amqp_basic_properties_t props;
props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG;
props.content_type = amqp_cstring_bytes("text/plain");
props.delivery_mode = 2; /* persistent delivery mode */
int errorcode = amqp_basic_publish(conn,
1,
amqp_cstring_bytes(exchange),
amqp_cstring_bytes(routingkey),
0,
0,
&props,
amqp_cstring_bytes(Message));
if (errorcode != 0) {
UE_LOG(TILES, Error, TEXT("Publishing error"));
}
//UE_LOG(TILES, Warning, TEXT("Published Message %s"), Message);
return true;
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include <amqp_tcp_socket.h>
#include <amqp.h>
#include <amqp_framing.h>
#include "RabbitMQConnection.generated.h"
/**
*
*/
UCLASS()
class MASTERTESTPROJECT_API URabbitMQConnection : public UObject
{
GENERATED_BODY()
public:
bool success = false;
amqp_socket_t *socket = NULL;
amqp_connection_state_t conn;
URabbitMQConnection(const FObjectInitializer& ObjectInitializer);
~URabbitMQConnection();
bool publishMessage(char const * Message);
protected:
};
...@@ -24,10 +24,6 @@ void AVRPawnCode::BeginPlay() ...@@ -24,10 +24,6 @@ void AVRPawnCode::BeginPlay()
UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance()); UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance());
if (gameinstance != nullptr && !gameinstance->connection) {
gameinstance->connection = NewObject<URabbitMQConnection>();
}
char const *messagebody = "{\"timestamp\":15.600000381469727,\"start\":{\"x\":0.0,\"y\":0.0,\"z\":0.0},\"end\":{\"x\":1.0,\"y\":5.0,\"z\":16.0}}"; char const *messagebody = "{\"timestamp\":15.600000381469727,\"start\":{\"x\":0.0,\"y\":0.0,\"z\":0.0},\"end\":{\"x\":1.0,\"y\":5.0,\"z\":16.0}}";
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/Pawn.h" #include "GameFramework/Pawn.h"
#include "RabbitMQConnection.h"
#include "UDPSender.h" #include "UDPSender.h"
#include "VRPawnCode.generated.h" #include "VRPawnCode.generated.h"
...@@ -33,7 +32,7 @@ public: ...@@ -33,7 +32,7 @@ public:
// Called to bind functionality to input // Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
UFUNCTION(BlueprintCallable, Category = "RabbitMQ") UFUNCTION(BlueprintCallable, Category = "UDP")
void PublishMessage(FVector start, FVector end, AUDPSender *socket); void PublishMessage(FVector start, FVector end, AUDPSender *socket);
......
Subproject commit 1ab85f16ff687c214ebe61a1f598b3de60fe2487 Subproject commit 123d06ca1c7ceb632883afc15adac9d613ecd0f6
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment