Hi there,
I’ve had an in-depth look at both the Boss-Room and Game-Lobby-Sample example projects, however, I still can’t figure out why relay integrations won’t work for me?
Is there any other setup required, other than what is specified in the documentation, for relay integrations to work?
Here are my Join and Create methods:
public async void Join(string lobbyId, string password = "")
{
...
try
{
// Authenticate
await Authenticate();
// Join Lobby
...
LobbyPlayer player = new LobbyPlayer(AuthenticationService.Instance.PlayerId);
JoinLobbyByIdOptions options = new JoinLobbyByIdOptions()
{
Player = player
};
Lobby lobby = = await LobbyHelper.Instance.JoinLobbyByIdAsync(lobbyId, options);
...
// Join Relay
string joinCode = lobby.Data["joinCode"].Value;
JoinAllocation join = await Relay.Instance.JoinAllocationAsync(joinCode);
await Lobbies.Instance.UpdatePlayerAsync(lobby.Id, player.Id, new UpdatePlayerOptions()
{
AllocationId = join.AllocationId.ToString(),
ConnectionInfo = joinCode
});
relayTransport.SetClientRelayData(join.RelayServer.IpV4, (ushort)join.RelayServer.Port, join.AllocationIdBytes, join.Key, join.ConnectionData, join.HostConnectionData, true);
...
// Start Client
...
NetworkManager.Singleton.StartClient();
}
catch (Exception e)
{
...
}
}
public async void Create()
{
...
try
{
// Authenticate
await Authenticate();
...
// Allocate Relay
...
Allocation allocation = await Relay.Instance.CreateAllocationAsync(maxPlayers);
relayTransport.SetHostRelayData(allocation.RelayServer.IpV4, (ushort)allocation.RelayServer.Port, allocation.AllocationIdBytes, allocation.Key, allocation.ConnectionData, true);
...
// Generate Join Code
...
string joinCode = await Relay.Instance.GetJoinCodeAsync(allocation.AllocationId);
// Create Lobby
...
CreateLobbyOptions options = new CreateLobbyOptions()
{
IsPrivate = isPrivate,
Data = new Dictionary<string, DataObject>()
{
{ "joinCode", new DataObject(DataObject.VisibilityOptions.Public, joinCode) },
...
},
Player = new LobbyPlayer(AuthenticationService.Instance.PlayerId, joinCode, null, allocation.AllocationId.ToString())
};
Lobby lobby = await LobbyHelper.Instance.CreateLobbyAsync(worldNameInputField.text, maxPlayers, options);
// Start Host
...
NetworkManager.Singleton.StartHost();
}
catch (Exception e)
{
...
}
}
Thank you in advance!