示例#1
0
        /// <summary>
        ///     Sends the current admin state of a player on a server to the client
        /// </summary>
        /// <param name="entry">Socket host name of the peer</param>
        /// <param name="admin">Admin state to send to the client</param>
        private void SendAdminStateToClient(string entry, bool admin)
        {
            var clientId = ZNet.instance.m_peers.FirstOrDefault(x => x.m_socket.GetHostName() == entry)?.m_uid;

            if (clientId != null)
            {
                Logger.LogInfo($"Sending admin status to {entry}/{clientId} ({(admin ? "is admin" : "is no admin")})");
                var pkg = new ZPackage();
                pkg.Write(admin);
                AdminRPC.SendPackage(clientId.Value, pkg);
            }
        }
示例#2
0
        private IEnumerator NonblockingRPC_OnServerReceive(long sender, ZPackage package)
        {
            Jotunn.Logger.LogMessage($"Received blob, processing");

            string dot = string.Empty;

            for (int i = 0; i < 5; ++i)
            {
                dot += ".";
                Jotunn.Logger.LogMessage(dot);
                yield return(new WaitForSeconds(1f));
            }

            Jotunn.Logger.LogMessage($"Broadcasting to all clients");
            NonblockingRPC.SendPackage(ZNet.instance.m_peers, new ZPackage(package.GetArray()));
        }
示例#3
0
        private IEnumerator BlockingRPC_OnServerReceive(long sender, ZPackage package)
        {
            Jotunn.Logger.LogMessage($"Received blob");

            if (BlockingRPC.IsSending)
            {
                Jotunn.Logger.LogMessage($"RPC is currently broadcasting packages, discarding");
                yield break;
            }

            string dot = string.Empty;

            for (int i = 0; i < 5; ++i)
            {
                dot += ".";
                Jotunn.Logger.LogMessage(dot);
                yield return(new WaitForSeconds(1f));
            }

            Jotunn.Logger.LogMessage($"Broadcasting to all clients");
            BlockingRPC.SendPackage(ZNet.instance.m_peers, new ZPackage(package.GetArray()));
        }