Skip to content

charisma-ai/colyseus-unreal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



Patreon donate button Discussion forum

Multiplayer Game Client for Unreal Engine.
View documentation

Example

#include "Client.h"
#include "Room.h"

const FString UMyComponent::SocketURL = TEXT("https://my-url.com");

struct FMyMessageStruct
{
	int Id;
	std::string Name;
	std::string Text;

	// You can rename fields!
	MSGPACK_DEFINE_MAP(MSGPACK_NVP("id", Id), MSGPACK_NVP("name", Name), MSGPACK_NVP("text", Text));
};

void UMyComponent::Connect()
{
	ClientInstance = MakeShared<Client>(SocketURL);
	ClientInstance->JoinOrCreate<void>("room_name", {{"room_option", "option_value"}},
		[this](TSharedPtr<MatchMakeError> Error, TSharedPtr<Room<void>> Room)
		{
			if (Error)
			{
				UE_LOG(/* oh dear! */)
				return;
			}

			UE_LOG(/* connected! */)

			this->RoomInstance = Room;

			this->RoomInstance->OnMessage("message_type",
				[](const msgpack::object& Message)
				{
					FMyMessageStruct Event = Message.as<FMyMessageStruct>();
					// Do something with the event...!
				});
		});
}

Contributors

Big thanks to Hung Hoang for making the Cocos2D C++ implementation of this client, which the Unreal Engine implementation is based on.

License

MIT

About

⚔️ Colyseus Multiplayer SDK for Unreal Engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published