First question:
I want to be able to create a channel that is password protected that hosts the multiplayer lobby once a user creates a server. However, for other reasons, I also need the channel's id so I can assign it to my network manager script. So with that in mind, is there a way to get the channels id after creating it? And when should the channel be created? In the OnConnect event? - (cause if so, it doesn't appear to be working.)
Second question:
I was under the impression that once a connection has been established (the OnConnect event) you can start using the TNManager.SetHost and TNManager.SetServerData functionality however this doesn't appear to be the case.
My OnConnect method:
protected override void OnConnect(bool success, string message)
{
Debug.Log("Connected to " + ServerInfo.ExternalAddress + ": " + success + " " + message + " (Player ID #" + TNManager.playerID + ")");
if (ServerInfo.IsHost == true)
{
TNManager.CreateChannel(null, false, MaxPlayers, (string.IsNullOrEmpty(ServerInfo.Password)) ? null : ServerInfo.Password, true);
TNManager.SetHost(ChannelId, TNManager.GetPlayer(TNManager.playerID));
TNManager.SetServerData("serverIsPasswordProtected", (string.IsNullOrEmpty(ServerInfo.Password)) ? false : true);
TNManager.SetServerData("serverHost", TNManager.GetHost(ChannelId));
}
if (TNManager.GetServerData<bool>("serverIsPasswordProtected") == true)
UIPasswordWindow.Show(ChannelId, null);
else
TNManager.JoinChannel(ChannelId, null, false, MaxPlayers, null);
}
but my watch window is giving me:
TNManager.channels.size 0 System.Int32
TNManager.GetHost(ChannelId) null System.Object
TNManager.GetServerData("serverIsPasswordProtected") null System.Object
TNManager.GetServerData("serverHost"); null System.Object
As far as I can tell, the the values are never being stored. So how would someone use these methods?
Side note, the 'ServerInfo' class is a static class used by the network manager to track certain bits of information, including the IsHost flag which is only set to true for the person that creates the server and also has a property for IsGuest for people that join the server. Thank you for any and all help!