Exemplo n.º 1
0
        private void OnUserSearch(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("User search request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            string name     = msg.Parms.GetStringProperty(2).Trim();
            string email    = msg.Parms.GetStringProperty(3).Trim();
            Guid   guid     = msg.Parms.GetGuidProperty(4);
            int    page     = msg.Parms.GetIntProperty(5).GetValueOrDefault(0);
            int    pageSize = msg.Parms.GetIntProperty(6).GetValueOrDefault(0);
            string ip       = msg.Parms.GetStringProperty(7).Trim();

            WispUsersInfo users = new WispUsersInfo();

            users.AllowRemoteConnections = ZeusServer.AllowRemote;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, users);
            r.ReplyPacket.Parms.SetProperty(3, name);
            r.ReplyPacket.Parms.SetProperty(4, email);
            r.ReplyPacket.Parms.SetProperty(5, guid);
            r.ReplyPacket.Parms.SetProperty(6, page);
            r.ReplyPacket.Parms.SetProperty(7, pageSize);
            r.ReplyPacket.Parms.SetProperty(8, ip);
            users.TotalUserCount = -1;
            if (MyServer.RequireAuthentication)
            {
                r.ReplyPacket.Parms.SetProperty(2, SearchDBUsers(name, email, guid, ip, page, pageSize));
            }
        }
Exemplo n.º 2
0
        private void OnCharacterCreateRequest(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            string rsltMsg           = "";
            ServerCharacterInfo ci   = null;

            if (MyServer.UseCharacters)
            {
                ci = CharacterUtil.Instance.CreateNewCharacter(msg.Parms, ServerUser);
            }

            ReplyType rslt = ReplyType.Failure;

            if (ci != null && OnValidateCharacterCreateRequest(ci, ref rsltMsg))
            {
                if (CharacterUtil.Instance.PersistNewCharacter(ci, ServerUser, ref rsltMsg, !MyServer.RequireAuthentication))
                {
                    rslt = ReplyType.OK;
                }
            }

            PacketReply rep = CreateStandardReply(msg, rslt, rsltMsg);

            msg.ReplyPacket = rep;
        }
Exemplo n.º 3
0
        private void OnUserOverviewRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("User overview request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            int pageNum  = msg.Parms.GetIntProperty(2).GetValueOrDefault(0);
            int pageSize = msg.Parms.GetIntProperty(3).GetValueOrDefault(50);

            if (!ServerUser.Profile.IsUserInRole("ActiveCustomerService"))
            {
                Log1.Logger("Server.Commands").Warn("[" + ServerUser.AccountName + "] has insufficient permissions to request user info.");
                r.ReplyPacket = CreateStandardReply(r, ReplyType.Failure, "Insufficient permissions. Only Administrators can request Zeus users.");
                return;
            }

            WispUsersInfo users = new WispUsersInfo();

            users.AllowRemoteConnections = ZeusServer.AllowRemote;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, users);
            users.TotalUserCount = -1;

            if (MyServer.RequireAuthentication)
            {
                int totalUsers = 0;
                Membership.GetAllUsers(0, 1, out totalUsers);
                users.TotalUserCount = totalUsers;
                users.UserDataStore  = "Database";
            }
        }
Exemplo n.º 4
0
        private void OnLogRequest(INetworkConnection con, Packet r)
        {
            PacketGenericMessage msg = r as PacketGenericMessage;

            Log1.Logger("Zeus").Debug("Log request from " + ServerUser.AccountName);

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.IsCompressed = true;

            Hierarchy h = LogManager.GetRepository() as Hierarchy;

            LimitedMemoryLogAppender memoryAppender = h.Root.GetAppender("MemoryAppender") as LimitedMemoryLogAppender;

            string[]       filters = msg.Parms.GetStringArrayProperty(2);
            LoggingEvent[] evts    = memoryAppender.GetEvents();
            List <string>  logs    = new List <string>();

            for (int i = 0; i < evts.Length; i++)
            {
                for (int x = 0; x < filters.Length; x++)
                {
                    if (evts[i].LoggerName == filters[x])
                    {
                        logs.Add(string.Format("[{2}]\t =>{0}\t: {1}", evts[i].TimeStamp.ToUniversalTime().ToString("hh:mm:ss tt"), evts[i].RenderedMessage, evts[i].Level.Name));
                    }
                }
            }

            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, logs.ToArray());
        }
Exemplo n.º 5
0
        private void OnUserAddServiceNoteRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus.Inbound.Client").Debug("Add service note request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            Guid   account = msg.Parms.GetGuidProperty(2);
            string note    = msg.Parms.GetStringProperty(3);

            if (note.Trim().Length < 1)
            {
                r.ReplyPacket.ReplyMessage = "Can't add a blank message.";
                r.ReplyPacket.ReplyCode    = ReplyType.Failure;
                return;
            }

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, account);

            if (!DB.Instance.User_CreateServiceLogEntry(account, "Service Note", ServerUser.AccountName, note, -1))
            {
                r.ReplyPacket.ReplyCode    = ReplyType.Failure;
                r.ReplyPacket.ReplyMessage = "Database error while trying to add note.";
            }
        }
Exemplo n.º 6
0
        private void OnCharacterActivated(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            CharacterInfo        ci  = msg.Parms.GetComponentProperty((int)PropertyID.CharacterInfo) as CharacterInfo;

            CurrentCharacter = ci;
            FireCharacterActivated(this, EventArgs.Empty);
        }
Exemplo n.º 7
0
        private void OnRemoteCharacterDisconnected(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            int    id             = msg.Parms.GetIntProperty((int)PropertyID.CharacterId).GetValueOrDefault(-1);
            string transferTarget = msg.Parms.GetStringProperty((int)PropertyID.Name);

            Log1.Logger("Server.Outbound.Network").Info("Character id " + id + " disconnected from remote server.");
            OnRemoteCharacterDisconnected(con, id, transferTarget);
        }
Exemplo n.º 8
0
        private void OnCharacterHandoffComplete(INetworkConnection con, Packet msg)
        {
            PacketGenericMessage pck = msg as PacketGenericMessage;
            ServerCharacterInfo  ci  = pck.Parms.GetComponentProperty((int)PropertyID.CharacterInfo) as ServerCharacterInfo;
            Guid owner = pck.Parms.GetGuidProperty((int)PropertyID.Owner);

            Log1.Logger("Server.Outbound.Network").Info("Character [" + ci.CharacterName + "|#" + ci.ID.ToString() + "] completed transfer to " + ((OutboundServerConnection)con).Name);
            OnCharacterHandoffComplete(con, ci, owner);
        }
Exemplo n.º 9
0
        private void OnServiceOverviewRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Service overview request from " + ServerUser.AccountName + ".");
            PacketGenericMessage msg = r as PacketGenericMessage;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            string[] services = WispServices.GetInstalledServices();
            msg.ReplyPacket.Parms.SetProperty(2, services);
        }
Exemplo n.º 10
0
        private void OnUserDetailRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus.Inbound.Client").Debug("User detail request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            Guid user = msg.Parms.GetGuidProperty(2);

            WispUserDetail ud = new WispUserDetail();

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, ud);

            MembershipUser usr = Membership.GetUser(user, false);

            if (usr == null)
            {
                r.ReplyPacket.ReplyCode    = ReplyType.Failure;
                r.ReplyPacket.ReplyMessage = "User not found.";
            }
            else
            {
                ud.Email              = usr.Email;
                ud.ID                 = user;
                ud.IsApproved         = usr.IsApproved;
                ud.IsLocked           = usr.IsLockedOut;
                ud.LastLogin          = usr.LastLoginDate.ToUniversalTime();
                ud.LastPasswordChange = usr.LastPasswordChangedDate.ToUniversalTime();
                ud.Roles.AddRange(Roles.GetRolesForUser(usr.UserName));
                ud.Username  = usr.UserName;
                ud.UserSince = usr.CreationDate;

                ServerUser su = ConnectionManager.GetAuthorizedUser(usr.UserName, MyServer, PacketLoginRequest.ConnectionType.AssistedTransfer);
                ud.IsOnline = su != null;
                if (su != null)
                {
                    ud.CurrentLoginTime = su.Profile.CurrentLoginTime;
                }

                AccountProfile prof = null;
                prof = new AccountProfile(usr.UserName);
                prof.Load(MyServer.RequireAuthentication);

                ud.AddedProperties = prof.AddedProperties;
                ud.LoginSessions   = new List <AccountProfile.Session>(prof.AllSessions);

                if (!DB.Instance.User_GetServiceLogEntries(user, "", ud.ServiceNotes))
                {
                    ServiceLogEntry sle = new ServiceLogEntry();
                    sle.EntryBy = "System";
                    sle.Note    = "Unable to retrieve service log entries from database.";
                    ud.ServiceNotes.Add(sle);
                }

                ud.Characters = CharacterUtil.Instance.GetCharacterListing(user);
            }
        }
Exemplo n.º 11
0
        private void OnNotesArrived(INetworkConnection con, Packet packet)
        {
            PacketGenericMessage msg = packet as PacketGenericMessage;

            m_PatchNotes = msg.Parms.GetStringProperty("notes");
            if (PatchNotesArrived != null)
            {
                PatchNotesArrived((PatchServerConnection)con, PatchNotes);
            }
        }
Exemplo n.º 12
0
        public void OnPlayerLeaveGame(INetworkConnection sender, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            GameServerGame       g   = ServerUser.CurrentCharacter.GetCurrentGame();

            if (g != null)
            {
                g.RemovePlayer(ServerUser.CurrentCharacter, "left the game.", true);
                g.RemoveObserver(ServerUser.CurrentCharacter);
            }
        }
Exemplo n.º 13
0
        private void OnPerfMonStartRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Performance Monitor Start request from " + ServerUser.AccountName + ".");

            if (!ServerUser.Profile.IsUserInRole("Administrator"))
            {
                Log1.Logger("Zeus").Warn("[" + ServerUser.AccountName + "] has insufficient permissions to start performance monitor.");
                r.ReplyPacket = CreateStandardReply(r, ReplyType.Failure, "Insufficient permissions. Only Administrators can start the performance monitor.");
                return;
            }

            PacketGenericMessage msg = r as PacketGenericMessage;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            string[] counters = msg.Parms.GetStringArrayProperty(2);

            if (counters.Length == 0)
            {
                r.ReplyPacket.ReplyCode    = ReplyType.Failure;
                r.ReplyPacket.ReplyMessage = "Must specify at least one counter to start.";
                return;
            }

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < counters.Length; i++)
            {
                string      key = counters[i];
                PerfHistory h   = null;
                if (PerfMon.History.TryGetValue(key, out h))
                {
                    h.IsEnabled = true;
                    if (sb.Length == 0)
                    {
                        sb.Append("Enabled performance counter ");
                    }
                    sb.Append(key.Replace("|", " -> ") + ", ");
                }
            }

            if (sb.Length >= 2)
            {
                sb.Remove(sb.Length - 2, 1);
                PerfMon.InstallCounters();
                PerfMon.StartSamplingCounters();
            }
            else if (sb.Length == 0)
            {
                r.ReplyPacket.ReplyCode = ReplyType.Failure;
                sb.Append("No performance counters were activated.");
            }

            r.ReplyPacket.ReplyMessage = sb.ToString();
        }
Exemplo n.º 14
0
        private void OnPerfMonCounterOverviewRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Performance Monitor Counter overview request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            PerfHistory[] history = new PerfHistory[PerfMon.History.Count];
            PerfMon.History.Values.CopyTo(history, 0);
            msg.ReplyPacket.Parms.SetProperty(2, history);
            msg.ReplyPacket.Parms.SetProperty(3, PerfMon.IsSampling);
        }
Exemplo n.º 15
0
        private void OnMachineInfoRequest(INetworkConnection con, Packet packet)
        {
            bool cpu, gpu, drives, mainboard, os, ram;

            cpu = gpu = drives = mainboard = os = ram = false;

            PacketGenericMessage m = packet as PacketGenericMessage;

            m.ReplyPacket = CreateStandardReply(packet, ReplyType.OK, "");

            if (m.Parms.GetBoolProperty("cpu").GetValueOrDefault(false))
            {
                cpu = true;
                CPUInfo ci = MachineInfo.ReadCPUInfo();
                m.ReplyPacket.Parms.SetProperty("cpu", ci.ToString());
            }
            if (m.Parms.GetBoolProperty("gpu").GetValueOrDefault(false))
            {
                gpu = true;
                VideoCardInfo gi = MachineInfo.ReadGPUInfo();
                m.ReplyPacket.Parms.SetProperty("gpu", gi.ToString());
            }
            if (m.Parms.GetBoolProperty("drives").GetValueOrDefault(false))
            {
                drives = true;
                PatcherLib.DriveInfo di = MachineInfo.ReadLogicalDiskInfo();
                m.ReplyPacket.Parms.SetProperty("drives", di.ToString());
            }
            if (m.Parms.GetBoolProperty("mainboard").GetValueOrDefault(false))
            {
                mainboard = true;
                MotherboardInfo mi = MachineInfo.ReadMotherboardInfo();
                m.ReplyPacket.Parms.SetProperty("mainboard", mi.ToString());
            }
            if (m.Parms.GetBoolProperty("os").GetValueOrDefault(false))
            {
                os = true;
                OperatingSystemInfo osr = MachineInfo.ReadOperatingSystemInfo();
                m.ReplyPacket.Parms.SetProperty("os", osr.ToString());
            }
            if (m.Parms.GetBoolProperty("ram").GetValueOrDefault(false))
            {
                ram = true;
                RamInfo ri = MachineInfo.ReadRAMInfo();
                m.ReplyPacket.Parms.SetProperty("ram", ri.ToString());
            }

            if (MachineInfoRequestArrived != null)
            {
                MachineInfoRequestArrived(cpu, gpu, mainboard, drives, os, ram);
            }
        }
Exemplo n.º 16
0
        private void OnPatchInfoRequest(INetworkConnection con, Packet r)
        {
            PropertyBag bag = new PropertyBag();

            bag.SetProperty("MB", ((PatchServerProcess)MyServer).MBytesPatchDataSent);
            bag.SetProperty("Num", ((PatchServerProcess)MyServer).PatchFileSent);
            bag.SetProperty("Users", ConnectionManager.ConnectionCount);

            PacketGenericMessage msg = r as PacketGenericMessage;

            r.ReplyPacket       = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms = bag;
        }
Exemplo n.º 17
0
        private void OnServerCommandListRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Server command listing request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            string commandGroup      = msg.Parms.GetStringProperty(2).Trim();

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            List <CommandData> cmds = CommandManager.GetCommands(commandGroup);

            r.ReplyPacket.Parms.SetProperty(2, cmds.ToArray());
        }
        private void OnGameListingRequest(INetworkConnection con, Packet gmsg)
        {
            PacketMatchRefresh note = (PacketMatchRefresh)CreatePacket((int)LobbyPacketType.MatchRefresh, 0, false, false);

            note.IsServerPacket = false;
            note.IsRefresh      = true;
            note.ReplyCode      = ReplyType.OK;
            note.Kinds.Add(MatchNotificationType.ListingRefresh);
            note.TargetPlayers.Add(null);
            gmsg.ReplyPacket = note;

            if (!ValidateHasCurrentCharacter())
            {
                note.ReplyMessage = "You must select a character before you can receive a content listing.";
                note.ReplyCode    = ReplyType.Failure;
                return;
            }

            PacketGenericMessage gp = gmsg as PacketGenericMessage;
            int  page              = gp.Parms.GetIntProperty("Page").GetValueOrDefault(0);
            int  numPerPage        = gp.Parms.GetIntProperty("NumPerPage").GetValueOrDefault(50);
            bool includeInProgress = gp.Parms.GetBoolProperty("IncludeInProgress").GetValueOrDefault(true);
            int  minPlayersAllowed = gp.Parms.GetIntProperty("MinPlayersAllowed").GetValueOrDefault(0);

            string    msg         = "";
            DataTable dt          = DB.Instance.Lobby_GetGameListing(page, numPerPage, "", includeInProgress, minPlayersAllowed, gp.Parms, out msg);
            bool      gotRowCount = false;

            if (dt != null)
            { // Transform data result into game object
                foreach (DataRow r in dt.Rows)
                {
                    if (!gotRowCount)
                    {
                        gotRowCount = true;
                        note.Parms.SetProperty("TotalGames", (int)r["TotalRows"]);
                    }
                    Game g = new Game();
                    g.GameID     = (Guid)r["GameID"];
                    g.Started    = (bool)r["InProgress"];
                    g.MaxPlayers = (int)r["MaxPlayersAllowed"];
                    g.Name       = (string)r["GameName"];
                    g.Properties.SetProperty("IsPrivate", (bool)r["IsPrivate"]);
                    g.Properties.SetProperty("PlayerCount", (int)r["CurrentPlayers"]);
                    // allow custom searches to add their additional data to the game object
                    OnGameSearchResultTransform(g, r);
                    note.TheGames.Add(g);
                }
            }
        }
Exemplo n.º 19
0
        public void OnRequestStartGame(INetworkConnection sender, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;

            msg.ReplyPacket = CreateStandardReply(msg, ReplyType.Failure, "");
            try
            {
                GameServerGame game = ServerUser.CurrentCharacter.GetCurrentGame();
                if (!game.IsPlayerPartOfGame(ServerUser.CurrentCharacter.ID))
                {
                    KillConnection("Tried to send game packets to game that we're not part of any more.");
                    return;;
                }

                if (!game.GameStartStrategy.CanGameBeStartedManually)
                {
                    game.SendGameInfoMessageToPlayer(ServerUser.CurrentCharacter, "Game will be started automatically when ready.");
                    return;
                }

                if (!game.GameStartStrategy.DoesGameMeetStartConditions)
                {
                    game.SendGameInfoMessageToPlayer(ServerUser.CurrentCharacter, "Game can't be started yet.");
                    return;
                }

                if (game.Owner != ServerUser.CurrentCharacter.ID)
                {
                    // send a nag message
                    game.BroadcastGameInfoMessage(ServerUser.CurrentCharacter.CharacterName + " is requesting that we begin. Leader, please start game if ready.", true);
                    return;
                }

                string tmsg = "";
                if (!OnPlayerRequestStartGame(msg, ref tmsg) || !game.StartGame(ref tmsg, true))
                {
                    msg.ReplyPacket.ReplyMessage = tmsg;
                    return;
                }

                // if it succeeded, no need to send the reply packet as everyone will have received a game started message from game.StartGame()
                msg.NeedsReply = false;
            }
            catch (Exception e)
            {
                msg.ReplyPacket.ReplyMessage = "Unknown error occured OnRequestStartGame.";
                Log.LogMsg("[" + ServerUser.AccountName + "] failed to start game. " + e.Message);
            }
        }
Exemplo n.º 20
0
        private void OnPerfMonCounterDataRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus.Inbound.Client").Debug("Performance Monitor Counter data request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            string[]   counters  = msg.Parms.GetStringArrayProperty(2);
            DateTime[] lastCheck = msg.Parms.GetDateTimeArrayProperty(3);

            msg.ReplyPacket.Parms.SetProperty(3, DateTime.UtcNow);

            List <PerfHistory> clientHistories = new List <PerfHistory>();

            for (int i = 0; i < counters.Length; i++)
            {
                PerfHistory serverHistory = null;
                if (PerfMon.History.TryGetValue(counters[i], out serverHistory))
                {
                    Log.LogMsg("Got request for perf log " + serverHistory.Key + " since " + lastCheck[i].ToLongTimeString());
                    PerfHistory clientHis = new PerfHistory(serverHistory);
                    List <PerfHistory.HistoryItem> buff = new List <PerfHistory.HistoryItem>();
                    for (int x = serverHistory.History.Count - 1; x > -1; x--)
                    {
                        if (serverHistory.History[x].Timestamp > lastCheck[i])
                        {
                            //Log.LogMsg("Adding perf item " + ph.Key + " with timestamp " + ph.History[x].Timestamp.ToLongTimeString());
                            buff.Add(serverHistory.History[x]);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (buff.Count > 0)
                    {
                        clientHistories.Add(clientHis);
                        buff.Reverse();
                        clientHis.History.AddRange(buff);
                        clientHis.HelpText += " (" + clientHis.History[clientHis.History.Count - 1].Value + ")";
                        Log.LogMsg("Last timestamp sent for perf " + clientHis.Key + " is " + clientHis.LastSample.ToLongTimeString());
                    }
                }
            }

            msg.ReplyPacket.Parms.SetProperty(2, clientHistories.ToArray());
        }
Exemplo n.º 21
0
        private void OnCharacterDeleteRequest(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            string    rsltMsg        = "";
            ReplyType rslt           = ReplyType.Failure;
            int       characterId    = msg.Parms.GetIntProperty((int)PropertyID.CharacterId).GetValueOrDefault();

            if (MyServer.UseCharacters && MyServer.RequireAuthentication && CharacterUtil.Instance.DeleteCharacter(characterId, ServerUser, false, "Player requested deletion from [" + con.RemoteEndPoint.ToString() + "].", ref rsltMsg))
            {
                rslt = ReplyType.OK;
            }

            PacketReply rep = CreateStandardReply(msg, rslt, rsltMsg);

            msg.ReplyPacket = rep;
        }
        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.º 24
0
        private void OnLogOverviewRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Log overview request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            int id = msg.Parms.GetIntProperty(2).GetValueOrDefault(-1);

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");

            log4net.ILog[] loggers     = log4net.LogManager.GetCurrentLoggers();
            string[]       LogChannels = new string[loggers.Length];

            for (int i = 0; i < LogChannels.Length; i++)
            {
                LogChannels[i] = loggers[i].Logger.Name;
            }

            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, LogChannels);
        }
Exemplo n.º 25
0
        private void OnConfigSaveRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Config save request from " + ServerUser.AccountName + ".");
            Log1.Logger("Zeus").Info("[" + ServerUser.AccountName + "] attempting to save server config...");

            if (!ServerUser.Profile.IsUserInRole("Administrator"))
            {
                Log1.Logger("Zeus").Warn("[" + ServerUser.AccountName + "] has insufficient permissions to save configs.");
                r.ReplyPacket = CreateStandardReply(r, ReplyType.Failure, "Insufficient permissions. Only Administrators can update configs.");
                return;
            }

            PacketGenericMessage        msg        = r as PacketGenericMessage;
            WispConfigSettings          cfg        = msg.Parms.GetWispProperty(1) as WispConfigSettings;
            Dictionary <string, string> newConfigs = cfg.Configs;

            string msgs  = "";
            bool   rsult = MyServer.SaveConfigs(newConfigs, true, false, ref msgs);

            r.ReplyPacket = CreateStandardReply(r, rsult ? ReplyType.OK : ReplyType.Failure, msgs);
        }
Exemplo n.º 26
0
        private void OnChangeServiceStateRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Service state change request from " + ServerUser.AccountName + ".");
            if (!ServerUser.Profile.IsUserInRole("Administrator"))
            {
                Log1.Logger("Zeus").Warn("[" + ServerUser.AccountName + "] has insufficient permissions to change service state.");
                r.ReplyPacket = CreateStandardReply(r, ReplyType.Failure, "Insufficient permissions. Only Administrators can change service states.");
                return;
            }

            PacketGenericMessage msg = r as PacketGenericMessage;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");

            string service     = msg.Parms.GetStringProperty(2);
            string targetState = msg.Parms.GetStringProperty(3);
            string result      = "";

            Log1.Logger("Zeus").Debug(ServerUser.AccountName + " requested that [" + service + "] change state to [" + targetState + "].");

            if (targetState.ToLower() == "start")
            {
                result = WispServices.StartWispService(service);
            }
            else if (targetState.ToLower() == "stop")
            {
                result = WispServices.StopWispService(service);
            }
            else if (targetState.ToLower() == "uninstall")
            {
                result = WispServices.UninstallService(service);
                //int idx = MyServer.OutboundServerGroups["Default"].OutboundServers.Find(s=>s.n
            }

            r.ReplyPacket.ReplyMessage = result;

            Log1.Logger("Zeus").Debug(ServerUser.AccountName + " requested service state change for [" + service + "] to state [" + targetState + "] result: [" + result + "].");
            string[] services = WispServices.GetInstalledServices();
            msg.ReplyPacket.Parms.SetProperty(2, services);
        }
Exemplo n.º 27
0
        private void OnUserCreateRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus.").Debug("User creation request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            string name     = msg.Parms.GetStringProperty(2).Trim();
            string email    = msg.Parms.GetStringProperty(3).Trim();
            string password = msg.Parms.GetStringProperty(4).Trim();

            string[] roles = msg.Parms.GetStringArrayProperty(5);

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, name);
            r.ReplyPacket.Parms.SetProperty(3, email);

            List <string> oroles = new List <string>();

            for (int i = 0; i < roles.Length; i++)
            {
                if (roles[i].Trim().Length > 0)
                {
                    oroles.Add(roles[i].Trim());
                }
            }

            string         omsg    = "";
            MembershipUser newUser = CreateNewAccount(name, password, email, oroles.ToArray(), ref omsg);

            if (newUser == null)
            {
                r.ReplyPacket.ReplyCode    = ReplyType.Failure;
                r.ReplyPacket.ReplyMessage = omsg;
            }
            else
            {
                r.ReplyPacket.Parms.SetProperty(4, (Guid)newUser.ProviderUserKey);
            }
        }
Exemplo n.º 28
0
        private void OnCharacterDetailRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus.Inbound.Client").Debug("Character detail request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            int id = msg.Parms.GetIntProperty(2).GetValueOrDefault(-1);
            WispCharacterDetail ci = new WispCharacterDetail(id);
            string rmsg            = "";

            ServerUser su = new Shared.ServerUser();

            su.ID = Guid.Empty;
            ServerCharacterInfo sci = null;

            if (MyServer.RequireAuthentication)
            {
                sci = CharacterUtil.Instance.LoadCharacter(su, id, ref rmsg);
            }

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.ReplyMessage = rmsg;

            if (sci == null)
            {
                r.ReplyPacket.ReplyCode    = ReplyType.Failure;
                r.ReplyPacket.ReplyMessage = "Character not found. " + rmsg;
            }
            else
            {
                ci.CharacterName = sci.CharacterInfo.CharacterName;
                ci.ID            = sci.ID;
                ci.LastLogin     = sci.LastLogin;
                ci.Properties    = sci.Properties;
                ci.Stats         = sci.Stats;

                r.ReplyPacket.Parms.SetProperty(2, ci as ISerializableWispObject);
            }

            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
        }
Exemplo n.º 29
0
        private void OnServerCommandExecuteRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("Server command execution request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            string commandName       = msg.Parms.GetStringProperty(2).Trim();

            string[] parms = msg.Parms.GetStringArrayProperty(3);

            // if this message is coming from another server, we should have the roles in the message, if
            // not, then its coming from a user and we should have the roles in the user profile
            string[] roles = ServerUser.IsAuthorizedClusterServer ? msg.Parms.GetStringArrayProperty("Roles") : ServerUser.Profile.UserRoles;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);

            string result = CommandManager.ExecuteCommand(ServerUser.AccountName, roles, commandName, parms);

            r.ReplyPacket.Parms.SetProperty(2, commandName);
            r.ReplyPacket.Parms.SetProperty(3, parms);
            r.ReplyPacket.Parms.SetProperty(4, result);
        }
        private void OnQuickMatchRequest(INetworkConnection con, Packet gmsg)
        {
            PacketQuickMatchResult note = (PacketQuickMatchResult)CreatePacket((int)LobbyPacketType.QuickMatchResult, 0, false, false);

            gmsg.ReplyPacket = note;

            if (!ValidateHasCurrentCharacter())
            {
                note.ReplyMessage = "You must select a character before you can get a quick match .";
                note.ReplyCode    = ReplyType.Failure;
                return;
            }

            PacketGenericMessage gp = gmsg as PacketGenericMessage;

            string msg = "";

            gp.Parms.SetProperty("QuickMatch", true);
            DataTable dt          = DB.Instance.Lobby_GetQuickMatch(gp.Parms, out msg);
            bool      gotRowCount = false;

            if (dt != null)
            { // Transform data result into game object
                foreach (DataRow r in dt.Rows)
                {
                    note.ReplyCode = ReplyType.OK;
                    Game g = new Game();
                    g.GameID     = (Guid)r["GameID"];
                    g.Started    = (bool)r["InProgress"];
                    g.MaxPlayers = (int)r["MaxPlayersAllowed"];
                    g.Name       = (string)r["GameName"];
                    g.Properties.SetProperty("IsPrivate", (bool)r["IsPrivate"]);
                    g.Properties.SetProperty("PlayerCount", (int)r["CurrentPlayers"]);
                    // allow custom searches to add their additional data to the game object
                    OnQuickMatchGameSearchResultTransform(g, r);
                    note.TheGame = g;
                }
            }
        }
Exemplo n.º 31
0
 protected virtual bool OnPlayerRequestStartGame(PacketGenericMessage msg, ref string info)
 {
     return true;
 }
Exemplo n.º 32
0
        public bool SendPacketAck(PacketGenericMessage packet)
        {
            bool rslt = true;

            PacketACK p = (PacketACK)CreatePacket((int)PacketType.ACK, 0, false, false);
            p.ReplyPacketID = packet.PacketID;
            p.ReplyCode = ReplyType.OK;
            p.ReplyPacketType = packet.PacketTypeID;
            p.ReplyPacketSubType = packet.PacketSubTypeID;
            p.IsUDP = packet.IsUDP;

            Send(p);
            return rslt;
        }