Beispiel #1
0
        public AceGameInfo CreateAceGameInfo(string gameName, string apianGroupType, int maxPlayers, int minValidators, int validatorWaitMs)
        {
            // TODO: does this belong here? Seems a little odd that it is here and CurrentGroupStatus() is in AceApian.
            // On the other hand, they really are kinda different and are created at different times.
            string netName = p2p.GetMainChannel()?.Name;

            if (netName == null)
            {
                logger.Error($"CreateAceGameInfo() - Must join network first"); // TODO: probably ought to assert? Can this be recoverable?
                return(null);
            }

            P2pNetChannelInfo groupChanInfo = new P2pNetChannelInfo(aceChannelData[kAceGameChannelInfo]);

            groupChanInfo.name = gameName;
            groupChanInfo.id   = $"{netName}/{gameName}";

            AceGameInfo gameInfo = new AceGameInfo(new ApianGroupInfo(apianGroupType, groupChanInfo, LocalP2pId(), gameName));

            gameInfo.MaxPlayers      = maxPlayers;
            gameInfo.MinValidators   = minValidators;
            gameInfo.ValidatorWaitMs = validatorWaitMs;

            return(gameInfo);
        }
Beispiel #2
0
        public async Task <PeerJoinedNetworkData> JoinGameNetworkAsync(string netName, AceNetworkPeer localPeer)
        {
            P2pNetChannelInfo chan = new P2pNetChannelInfo(aceChannelData[kAceNetworkChannelInfo]);

            chan.name = netName;
            chan.id   = netName;
            string beamNetworkHelloData = JsonConvert.SerializeObject(localPeer);

            return(await JoinNetworkAsync(chan, beamNetworkHelloData));
        }