Exemplo n.º 1
0
        public bool TransferToServerUnassisted(string address, int port, Guid contentID, string targetServerID, string targetServerName)
        {
            Log1.Logger("Server").Debug("Unassisted server transfer for user[" + AccountName + "] to [" + address + ":" + port.ToString() + ", " + targetServerID + "].");
            if (MyConnection != null && MyConnection.IsAlive)
            {
                RenewAuthorizationTicket(true, targetServerID);
                PacketGameServerTransferResult p = (PacketGameServerTransferResult)MyConnection.CreatePacket((int)PacketType.PacketGameServerAccessGranted, 0, true, true);
                p.AuthTicket = AuthTicket;
                p.ServerIP   = address;
                p.ServerPort = port;

                p.IsAssistedTransfer = false;
                p.TargetResource     = contentID;
                p.ServerName         = targetServerName;
                p.ReplyCode          = ReplyType.OK;
                p.ReplyMessage       = "";

                //this.TransferTarget = "";
                this.TransferTarget = targetServerID;

                MyConnection.Send(p);

                // set expiration
                AuthorizationExpires = DateTime.UtcNow + TimeSpan.FromSeconds(15);
                m_HasBeenTransferred = true;
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to transfer the player to a different server
        /// </summary>
        /// <param name="address"></param>
        /// <param name="port"></param>
        /// <param name="authTicket">auth ticket for assisted transfers only.  unassisted transfers don't need this (Guid.Empty)</param>
        /// <param name="contentID"></param>
        /// <param name="friendlyServerName"></param>
        /// <returns></returns>
        public bool TransferToServerAssisted(string address, int port, Guid authTicket, Guid contentID, string friendlyServerName, string targetServerID, string msg, ReplyType reply)
        {
            if (MyConnection != null && MyConnection.IsAlive)
            {
                PacketGameServerTransferResult p = (PacketGameServerTransferResult)MyConnection.CreatePacket((int)PacketType.PacketGameServerAccessGranted, 0, true, true);
                p.AuthTicket = authTicket;
                p.ServerIP   = address;
                p.ServerPort = port;

                p.IsAssistedTransfer = true;
                p.TargetResource     = contentID;
                p.ServerName         = friendlyServerName;
                p.ReplyCode          = reply;
                p.ReplyMessage       = msg;

                if (reply == ReplyType.OK)
                {
                    TransferTarget = targetServerID;
                }

                MyConnection.Send(p);
                return(true);
            }

            return(false);
        }