Exemplo n.º 1
0
        /// <summary>
        /// Transfers this connection to an available lobby server or, if there is no lobby server available, disconnects the player.
        /// </summary>
        public void TransferToLobbyOrDisconnect()
        {
            string address  = "";
            int    port     = 0;
            string serverId = "";

            if (!GetCentralHandoffAddress(ref address, ref port, ref serverId))
            {
                KillConnection("Unable to host player on this server.  No lobby server found to hand off too.");
                return;
            }

            ServerUser.TransferToServerUnassisted(address, port, Guid.Empty, "Lobby Server", serverId);
        }
        private void OnPlayerJoinGame(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage genMsg = gmsg as PacketGenericMessage;

            if (!ValidateHasCurrentCharacter())
            {
                return;
            }

            Guid gameId            = genMsg.Parms.GetGuidProperty((int)PropertyID.GameId);
            ServerCharacterInfo ci = ServerUser.CurrentCharacter;

            string address = "";
            int    port    = 0;
            string name    = "";

            Log1.Logger(MyServer.ServerUserID).Info(string.Format("Player {0} requesting join content '{1}'...", ServerUser.AccountName, gameId.ToString()));

            if (DB.Instance.Lobby_GetGameServer(gameId, out address, out port, out name) && address.Length > 0 && port > 0)
            {
                Log.LogMsg(string.Format("Transferring Player {0} to join content '{1}' on server @ {2} ...", ServerUser.AccountName, gameId.ToString(), address));

                PacketMatchNotification note = (PacketMatchNotification)CreatePacket((int)LobbyPacketType.MatchNotification, 0, false, false);
                note.Kind         = MatchNotificationType.PlayerAdded;
                note.TargetPlayer = ci.CharacterInfo;
                note.Parms        = genMsg.Parms;
                note.ReplyCode    = ReplyType.OK;
                Send(note);

                ServerUser.TransferToServerUnassisted(address, port, gameId, name, name);
            }
            else
            {
                Log.LogMsg(string.Format("Player {0} failed to join content '{1}' : {2} ...", ServerUser.AccountName, gameId.ToString(), "Couldn't find game. Join canceled."));
                PacketMatchNotification note = (PacketMatchNotification)CreatePacket((int)LobbyPacketType.MatchNotification, 0, false, false);
                note.ReplyMessage  = "Game couldn't be found. Strange...";
                note.Kind          = MatchNotificationType.PlayerAdded;
                note.TargetPlayer  = ci.CharacterInfo;
                note.Parms         = genMsg.Parms;
                note.ReplyCode     = ReplyType.Failure;
                genMsg.ReplyPacket = note;
                return;
            }
        }
        private void OnCreateNewGame(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage    genMsg = gmsg as PacketGenericMessage;
            PacketMatchNotification note   = (PacketMatchNotification)CreatePacket((int)LobbyPacketType.MatchNotification, 0, false, false);

            note.Kind       = MatchNotificationType.MatchCreated;
            note.NeedsReply = false;

            if (!ValidateHasCurrentCharacter())
            {
                genMsg.ReplyPacket = note;
                note.ReplyMessage  = "You must select a character before you can create a new game.";
                note.ReplyCode     = ReplyType.Failure;
                return;
            }

            //
            // <h2 style="text-align: center"><span style="color: #993300;"><a href="http://www.survivalnotes.org/content/category/fire"><span style="color: #993300;">Latest Entries</span></a>           <a href="http://www.survivalnotes.org/content/category/fire?r_sortby=highest_rated&amp;r_orderby=desc"><span style="color: #993300;">Highest Rated Entries</span></a></span></h2>
            // <h2 style="text-align: center"><span style="color: #993300;"><a href="http://www.survivalnotes.org/content/category/fire"><span style="color: #993300;">Latest Entries</span></a>           &nbsp;&nbsp;&nbsp;&nbsp;             <a href="http://www.survivalnotes.org/content/category/fire?r_sortby=highest_rated&amp;r_orderby=desc"><span style="color: #993300;">Highest Rated Entries</span></a></span></h2>
            //

            Log1.Logger(MyServer.ServerUserID).Info(string.Format("Player {0} requesting create new game '{1}' ...", ServerUser.AccountName, genMsg.Parms.GetStringProperty((int)PropertyID.Name)));
            string msg = "";

            GameServerInfo <OutboundServerConnection> gsi = RequestCreateNewGameServer(out msg);

            genMsg.ReplyPacket = note;
            note.ReplyMessage  = msg;
            if (gsi == null)
            {
                // Failed. Either no servers online, or they are full.
                note.ReplyCode = ReplyType.Failure;
                return;
            }
            else
            {
                // Contact that server and request a game be created.

                note.ReplyCode = ReplyType.OK;
                ServerUser.TransferToServerUnassisted(gsi.IP, gsi.Port, Guid.Empty, gsi.Name, gsi.UserID);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Phase 2: Player requests to play on a specified game server.  This method forwards that request to the game server.
        /// </summary>
        private void OnClusterHandoffRequest(INetworkConnection con, Packet msg)
        {
            PacketRequestHandoffToServerCluster packetRequestHandoffToServer = msg as PacketRequestHandoffToServerCluster;

            if (!ServerUser.IsAuthenticated)
            {
                KillConnection(" [" + ServerUser.AccountName + "] requested server hand off to [" + packetRequestHandoffToServer.TargetServerName + "] without being authenticated.");
            }

            GameServerInfo <OutboundServerConnection> gsi = GetServerInfo(packetRequestHandoffToServer.TargetServerName);

            if (gsi == null) // cluster offline or at capacity?
            {
                PacketGameServerTransferResult p = (PacketGameServerTransferResult)CreatePacket((int)PacketType.PacketGameServerAccessGranted, 0, true, true);
                p.ReplyMessage = "Game service not currently available.";
                p.ReplyCode    = ReplyType.Failure;

                // send an updated listing of online servers
                string servers = "";
                foreach (GameServerInfoGroup gr in MyServer.OutboundServerGroups.Groups.Values)
                {
                    string serverInfo = gr.ID + "," + gr.HasLiveOutboundServerConnections;
                    servers += "|" + serverInfo;
                }

                servers = servers.Trim('|');
                p.Parms.SetProperty((int)PropertyID.ServerListing, servers);

                msg.ReplyPacket = p;
                return;
            }

            Log1.Logger("LoginServer.Inbound.Login").Info("Player " + ServerUser.AccountName + " is requesting handoff to game server " + gsi.Name);

            // request auth ticket from game server

            Log1.Logger("LoginServer.Inbound.Login").Debug("Requesting authenticated client *" + ServerUser.AccountName + "* (" + RemoteIP + ") to be handed off to server group " + packetRequestHandoffToServer.TargetServerName + ".");
            ServerUser.TransferToServerUnassisted(gsi.IP, gsi.Port, Guid.Empty, gsi.UserID, gsi.Name);
            //gsi.Connection.RequestPlayerHandoff(ServerUser.ID, ServerUser.AccountName, packetRequestHandoffToServer.TargetResource, ServerUser.Profile, null, "");
        }