/// <summary> /// Gets called when a game sub-server sends us a reply to our request to have a player play on that server. This method forwards that reply to the player. /// </summary> private void OnPlayerHandoffResult(INetworkConnection sender, Packet msg) { PacketPlayerAuthorizedForTransfer p = msg as PacketPlayerAuthorizedForTransfer; ServerUser playerCon = ConnectionManager.GetAuthorizedUser(p.AccountName, Server, PacketLoginRequest.ConnectionType.AssistedTransfer); if (playerCon != null) { Log1.Logger("Server.Outbound.Network").Info("Account [" + playerCon.AccountName + "] transfer request to " + Name + " reply: [" + p.ReplyCode.ToString() + "]. Forwarding result to player."); } OnPlayerHandoffResponseReceived(p, playerCon); }
/// <summary> /// Gets called when the parent server wishes to handoff a player off /// </summary> /// <param name="msg">request details</param> private void OnPlayerHandoffRequest(INetworkConnection con, Packet pck) { PacketRelayPlayerHandoffRequest msg = pck as PacketRelayPlayerHandoffRequest; // Create an auth ticket for the player, if we want to allow them to connect. ServerUser su = new ServerUser(); su.OwningServer = msg.OwningServer; su.AuthTicket = Guid.Empty; su.ID = msg.Player; su.AccountName = msg.AccountName; su.Profile = msg.Profile; if (msg.Character != null) { msg.Character.OwningAccount = su; su.CurrentCharacter = msg.Character; su.CurrentCharacter.TargetResource = msg.TargetResource; } string rmsg = ""; su.AuthTicket = OnPlayerConnectionRequest(su, ref rmsg); bool allowed = su.AuthTicket != Guid.Empty; if (allowed) { ConnectionManager.AuthorizeUser(su, false); if (msg.Character != null) { CharacterCache.CacheCharacter(su.CurrentCharacter, ServerUser.AccountName); } } PacketPlayerAuthorizedForTransfer p = (PacketPlayerAuthorizedForTransfer)CreatePacket((int)ServerPacketType.PacketPlayerAuthorizedForTransfer, 0, true, true); p.ReplyCode = allowed ? ReplyType.OK : ReplyType.Failure; p.Profile = msg.Profile; p.AccountName = msg.AccountName; p.AuthTicket = su.AuthTicket; p.ReplyMessage = allowed ? "Welcome to " + MyServer.ServerName + ", " + msg.AccountName : "Server is currently not accepting logins. Try again a little later. " + rmsg; p.Player = msg.Player; p.TargetResource = msg.TargetResource; msg.ReplyPacket = p; // reply will be sent by NetworkConnection.OnAfterPacketProcessed }
/// <summary> /// Gets called when we get a response to RequestPlayerHandoff(). Base method forwards a PacketGameServerAccessGranted packet to the player. /// Don't call the base method if you don't want that packet sent. /// </summary> protected virtual void OnPlayerHandoffResponseReceived(PacketPlayerAuthorizedForTransfer msg, ServerUser user) { if (user != null && RemoteEndPoint != null) { string targetServer = ""; IPEndPoint ep = RemoteEndPoint as IPEndPoint; if (msg.ReplyCode == ReplyType.OK) { targetServer = ServerUserID == null ? "Unknown Server User ID" : ServerUserID; } user.TransferToServerAssisted( ep.Address.ToString(), ep.Port, msg.AuthTicket, msg.TargetResource, Name == null ? "" : Name, targetServer, msg.ReplyMessage, msg.ReplyCode); } }