yojimbo: Problem with Unreal
Hi Glenn, I tried to integrate libyojimbo with unreal engine, after successfuly sending/receiving message with bare windows client to linux server, it’s failed doing excactling the same thing in Unreal Engine tutorial scene. I did some network sniffing with Wireshark, it’s weird the client side sends 10 UDP packets of 18 bytes payload to server, and server logged with “ignored encrypted packet, no read packet key for this address”, any ideas? Here’s my code (in Unreal).
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "physxClient.h"
#include "physxClientGameMode.h"
#include "physxClientHUD.h"
#include "physxClientCharacter.h"
#include "../ThirdParty/libyojimbo/include/yojimbo.h"
#include "../ThirdParty/libyojimbo/include/shared.h"
#include <signal.h>
using namespace yojimbo;
AphysxClientGameMode::AphysxClientGameMode()
: Super()
{
// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/FirstPersonCPP/Blueprints/FirstPersonCharacter"));
DefaultPawnClass = PlayerPawnClassFinder.Class;
// use our custom HUD class
HUDClass = AphysxClientHUD::StaticClass();
}
double ti = 100.0;
Client* client ;
void AphysxClientGameMode::StartPlay() {
Super::StartPlay();
InitializeYojimbo();
OgameMessageFactory messageFactory(GetDefaultAllocator());
uint64_t clientId = 1;
Address clientAddress("0.0.0.0", 6667);
Address serverAddress("192.168.0.8", 6666);
ClientServerConfig config;
config.numChannels = 1;
config.channel[0].type = CHANNEL_TYPE_UNRELIABLE_UNORDERED;
client = new Client(GetDefaultAllocator(), clientAddress, config, adapter, ti);
uint8_t privateKey[KeyBytes];
memset(privateKey, 0, KeyBytes);
client->InsecureConnect(privateKey, clientId, serverAddress);
client->AdvanceTime(ti);
}
void AphysxClientGameMode::Tick(float f) {
Super::Tick(f);
const double deltaTime = 0.1;
JoinMessage* message = (JoinMessage*)(client->CreateMessage(JOIN_MESSAGE));
message->teamId = 1;
client->SendMessage(0, message);
client->SendPackets();
client->ReceivePackets();
ti += deltaTime;
client->AdvanceTime(ti);
//messageFactory.ReleaseMessage(message);
yojimbo_sleep(deltaTime);
return;
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 41 (28 by maintainers)
Works for me