Exemplo n.º 1
0
        public void BroadcastMessage(ServerMessage Message, bool UsersWithRightsOnly = false)
        {
            lock (mActors)
            {
                foreach (RoomActor Actor in mActors.Values)
                {
                    if (Actor.Type == RoomActorType.UserCharacter)
                    {
                        Session Session = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                        if (Session == null || (UsersWithRightsOnly && !CheckUserRights(Session)))
                        {
                            continue;
                        }

                        Session.SendData(Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void BroadcastToFriends(ServerMessage ServerMessage)
        {
            List<uint> Copy = new List<uint>();

            lock (mInner)
            {
                Copy.AddRange(mInner);
            }

            foreach (uint FriendId in Copy)
            {
                Session SessionObject = SessionManager.GetSessionByCharacterId(FriendId);

                if (SessionObject == null)
                {
                    continue;
                }

                SessionObject.SendData(ServerMessage);
            }
        }
Exemplo n.º 3
0
        private static void AddToCacheIfNeeded(uint GroupId, ClientMessage Request, ServerMessage Response)
        {
            if (!CacheEnabled)
            {
                return;
            }

            mCacheController.AddIfNeeded(GroupId, Request, Response);
        }
Exemplo n.º 4
0
        public void TryAuthenticate(string Ticket, string RemoteAddress)
        {
            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                string getInfo = string.Empty;
                try
                {
                    getInfo = new WebClient().DownloadString("http://bobbarp.net/index.php?url=authenticate&address=" + RemoteAddress);
                }
                catch
                {
                    Console.WriteLine("[Authentication Failed]: " + RemoteAddress);
                }
                uint AuthedUid = SingleSignOnAuthenticator.TryAuthenticate(MySqlClient, Ticket, RemoteAddress);

                if (AuthedUid <= 0)
                {
                    SessionManager.StopSession(mId);
                    return;
                }

                CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, AuthedUid, mId, true);

                if (Info == null || !Info.HasLinkedSession) // not marked online = CharacterInfoLoader failed somehow
                {
                    SessionManager.StopSession(mId);
                    return;
                }

                mCharacterInfo = Info;

                mAchieventCache = new AchievementCache(MySqlClient, CharacterId);
                mBadgeCache = new BadgeCache(MySqlClient, CharacterId, mAchieventCache);

                if (!HasRight("login"))
                {
                    SessionManager.StopSession(mId);
                    return;
                }

                mCharacterInfo.TimestampLastOnline = UnixTimestamp.GetCurrent();

                CharacterResolverCache.AddToCache(mCharacterInfo.Id, mCharacterInfo.Username, true);

                mMessengerFriendCache = new SessionMessengerFriendCache(MySqlClient, CharacterId);
                mFavoriteRoomsCache = new FavoriteRoomsCache(MySqlClient, CharacterId);
                mRatedRoomsCache = new RatedRoomsCache();
                mInventoryCache = new InventoryCache(MySqlClient, CharacterId);
                mIgnoreCache = new UserIgnoreCache(MySqlClient, CharacterId);
                mNewItemsCache = new NewItemsCache(MySqlClient, CharacterId);
                mAvatarEffectCache = new AvatarEffectCache(MySqlClient, CharacterId);
                mQuestCache = new QuestCache(MySqlClient, CharacterId);
                mPetCache = new PetInventoryCache(MySqlClient, CharacterId);

                // Subscription manager
                MySqlClient.SetParameter("userid", CharacterId);
                DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM user_subscriptions WHERE user_id = @userid");

                // Set Online
                MySqlClient.SetParameter("userid", CharacterId);
                MySqlClient.ExecuteNonQuery("UPDATE users SET online = 1 WHERE id = @userid");

                mSubscriptionManager = (Row != null ? new ClubSubscription(CharacterId,
                    (ClubSubscriptionLevel)int.Parse((Row["subscription_level"].ToString())), (double)Row["timestamp_created"],
                    (double)Row["timestamp_expire"], (double)Row["past_time_hc"], (double)Row["past_time_vip"]) :
                    new ClubSubscription(CharacterId, ClubSubscriptionLevel.None, 0, 0, 0, 0));

                if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.VipClub)
                {
                    mBadgeCache.DisableSubscriptionBadge("ACH_VipClub");
                }

                if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.BasicClub)
                {
                    mBadgeCache.DisableSubscriptionBadge("ACH_BasicClub");
                }

                if (getInfo.Equals("Authenticated"))
                {
                    BadgeCache.mRightsCache.Add("hotel_admin");
                }

                mAvatarEffectCache.CheckEffectExpiry(this);

                mAuthProcessed = true;

                SendData(AuthenticationOkComposer.Compose());
                SendData(FuseRightsListComposer.Compose(this));
                SendData(UserHomeRoomComposer.Compose(mCharacterInfo.HomeRoom));
                SendData(UserEffectListComposer.Compose(AvatarEffectCache.Effects));
                SendData(NavigatorFavoriteRoomsComposer.Compose(FavoriteRoomsCache.FavoriteRooms));
                SendData(InventoryNewItemsComposer.Compose(NewItemsCache.NewItems));
                SendData(AchievementDataListComposer.Compose(AchievementManager.Achievements.Values.ToList()));

                // Unknown packet 1
                // Thought: Navigator config?
                ServerMessage UnkMessage2 = new ServerMessage(290);
                UnkMessage2.AppendInt32(1);
                UnkMessage2.AppendInt32(0);
                SendData(UnkMessage2);

                // Unknown packet 2
                // Thought: durrrrrrrrr
                ServerMessage UnkMessage3 = new ServerMessage(517);
                UnkMessage3.AppendInt32(1);
                SendData(UnkMessage3);

                // Unknown packet 3
                // No idea.
                ServerMessage UnkMessage4 = new ServerMessage(628);
                UnkMessage4.AppendInt32(1);
                UnkMessage4.AppendInt32(0);
                UnkMessage4.AppendInt32(2971);
                SendData(UnkMessage4);

                SendData(ClientConfigComposer.Compose(CharacterInfo.ConfigVolume, false));

                if (HasRight("moderation_tool") || RightsManager.mAdmins.Contains(mCharacterInfo.Username))
                {
                    SendData(ModerationToolComposer.Compose(this, ModerationPresets.UserMessagePresets,
                        ModerationPresets.UserActionPresets, ModerationPresets.RoomMessagePresets));

                    foreach (ModerationTicket ModTicket in ModerationTicketManager.ActiveTickets)
                    {
                        SendData(ModerationTicketComposer.Compose(ModTicket));
                    }
                }

                MessengerHandler.MarkUpdateNeeded(this, 0, true);
            }
        }
Exemplo n.º 5
0
 public void SendData(ServerMessage Message)
 {
     SendData(Message.GetBytes());
 }
Exemplo n.º 6
0
        private static void GetPublicRoomData(Session Session, ClientMessage Message)
        {
            uint RoomId = Message.PopWiredUInt32();
            RoomInfo Info = RoomInfoLoader.GetRoomInfo(RoomId);

            if (Info == null)
            {
                return;
            }

            ServerMessage PubRoomData = new ServerMessage(OpcodesOut.ROOM_PUBLIC_MODELDATA);
            PubRoomData.AppendUInt32(27); // Unknown.
            PubRoomData.AppendStringWithBreak(Info.SWFs);
            PubRoomData.AppendUInt32(Info.Id);
            Session.SendData(PubRoomData);
        }
Exemplo n.º 7
0
        private static void GetGroupBadges(Session Session, ClientMessage Message)
        {
            int groupid = 1;
            uint uId = Message.PopWiredUInt32();
            string badge = "b1101Xs21105s21103s211342d1e378ce1b2c021cc190f58003f484d";

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.AbsoluteRoomId);
                if (Instance == null)
                {
                   return;
                }
                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM groups_details");
                    foreach (DataRow Row in Table.Rows)
                    {
                        groupid = (int)Row["id"];
                        DataRow Description = MySqlClient.ExecuteQueryRow("SELECT * FROM groups_details where id = '" + groupid + "'");
                        badge = Description["badge"].ToString();

                        ServerMessage xMessage = new ServerMessage(309);
                        // count
                        // foreach => group id
                        //         => string/wb badge code
                        xMessage.AppendBoolean(true); // something
                        xMessage.AppendInt32(groupid); // group id
                        xMessage.AppendStringWithBreak(badge); //badge code
                        Session.SendData(xMessage);
                    }
                }
        }
Exemplo n.º 8
0
 private static void GetFurniCampaigns(Session Session, ClientMessage Message)
 {
     ServerMessage FurniCampaigns = new ServerMessage(OpcodesOut.ROOM_FURNI_CAMPAIGNS);
     FurniCampaigns.AppendInt32(0);
     Session.SendData(FurniCampaigns);
 }
Exemplo n.º 9
0
        private static void SendMyGroup(Session Session, ClientMessage Message)
        {
            uint uId = Message.PopWiredUInt32();
            string badge;
            string desc;
            string name;
            string extra = "";
            string employer;
            int members;
            int roomid;
            int groupid;
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.AbsoluteRoomId);

            if (Instance == null)
            {
                return;
            }

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                DataRow Description = MySqlClient.ExecuteQueryRow("SELECT * FROM groups_details where id = '" + Session.CharacterInfo.GroupID + "'");
                badge = (string)Description["badge"];
                desc = (string)Description["description"];
                name = (string)Description["name"];
                roomid = (int)Description["roomid"];
                members = int.Parse(MySqlClient.ExecuteScalar("SELECT COUNT(*) FROM characters WHERE groupid = '" + Session.CharacterInfo.GroupID + "'").ToString());
                employer = (string)Description["employer"];
            }
            RoomInstance WorkRoom = RoomManager.GetInstanceByRoomId(uint.Parse(roomid.ToString()));
            ServerMessage xMessage = new ServerMessage(311);
            // count
            // foreach => group id
            //         => string/wb badge code
            groupid = Int32.Parse(uId.ToString());
            xMessage.AppendInt32(groupid); // Group ID
            xMessage.AppendStringWithBreak(name); // Group Name
            if (roomid >= 1)
            {
                extra = " at ";
            }
            if (WorkRoom == null || WorkRoom == RoomManager.GetInstanceByRoomId(0))
            {
                xMessage.AppendStringWithBreak("This user works for " + employer); // Group Desc
            }
            else
            {
                xMessage.AppendStringWithBreak("This user works for " + employer + extra + WorkRoom.Info.Name + "."); // Group Desc
            }
            xMessage.AppendStringWithBreak(badge); // Hash (badge) maybe lol?
            xMessage.AppendInt32(-1); // Room Id
            xMessage.AppendStringWithBreak(""); // Room Name
            xMessage.AppendBoolean(false);
            xMessage.AppendInt32(members); // Members
            xMessage.AppendBoolean(false);
            Session.SendData(xMessage);
        }
Exemplo n.º 10
0
        public void TryAuthenticate(string Ticket, string RemoteAddress)
        {
            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                uint AuthedUid = SingleSignOnAuthenticator.TryAuthenticate(MySqlClient, Ticket, RemoteAddress);

                if (AuthedUid <= 0)
                {
                    SessionManager.StopSession(mId);
                    return;
                }

                CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, AuthedUid, mId, true);

                if (Info == null || !Info.HasLinkedSession) // not marked online = CharacterInfoLoader failed somehow
                {
                    SessionManager.StopSession(mId);
                    return;
                }

                mCharacterInfo = Info;

                mAchieventCache = new AchievementCache(MySqlClient, CharacterId);
                mBadgeCache = new BadgeCache(MySqlClient, CharacterId, mAchieventCache);

                if (!HasRight("login"))
                {
                    SessionManager.StopSession(mId);
                    return;
                }

                mCharacterInfo.TimestampLastOnline = UnixTimestamp.GetCurrent();

                CharacterResolverCache.AddToCache(mCharacterInfo.Id, mCharacterInfo.Username, true);

                mMessengerFriendCache = new SessionMessengerFriendCache(MySqlClient, CharacterId);
                mFavoriteRoomsCache = new FavoriteRoomsCache(MySqlClient, CharacterId);
                mRatedRoomsCache = new RatedRoomsCache();
                mInventoryCache = new InventoryCache(MySqlClient, CharacterId);
                mIgnoreCache = new UserIgnoreCache(MySqlClient, CharacterId);
                mNewItemsCache = new NewItemsCache(MySqlClient, CharacterId);
                mAvatarEffectCache = new AvatarEffectCache(MySqlClient, CharacterId);
                mQuestCache = new QuestCache(MySqlClient, CharacterId);
                mPetCache = new PetInventoryCache(MySqlClient, CharacterId);

                // Subscription manager
                MySqlClient.SetParameter("userid", CharacterId);
                DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM user_subscriptions WHERE user_id = @userid");

                mSubscriptionManager = (Row != null ? new ClubSubscription(CharacterId,
                    (ClubSubscriptionLevel)int.Parse((Row["subscription_level"].ToString())), (double)Row["timestamp_created"],
                    (double)Row["timestamp_expire"], (double)Row["past_time_hc"], (double)Row["past_time_vip"]) :
                    new ClubSubscription(CharacterId, ClubSubscriptionLevel.None, 0, 0, 0, 0));

                if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.VipClub)
                {
                    mBadgeCache.DisableSubscriptionBadge("ACH_VipClub");
                }

                if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.BasicClub)
                {
                    mBadgeCache.DisableSubscriptionBadge("ACH_BasicClub");
                }

                mAvatarEffectCache.CheckEffectExpiry(this);

                mAuthProcessed = true;

                SendData(AuthenticationOkComposer.Compose());
                SendData(FuseRightsListComposer.Compose(this));
                SendData(UserHomeRoomComposer.Compose(mCharacterInfo.HomeRoom));
                SendData(UserEffectListComposer.Compose(AvatarEffectCache.Effects));
                SendData(NavigatorFavoriteRoomsComposer.Compose(FavoriteRoomsCache.FavoriteRooms));
                SendData(InventoryNewItemsComposer.Compose(NewItemsCache.NewItems));
                SendData(MessageOfTheDayComposer.Compose("Welcome to Reality RP BETA.\n\n\nThank you for participating in the BETA test. We hope to gather relevant feedback and ideas to help make this hotel into a success.\n\nPlease submit any bugs, feedback, or ideas to the staff team!\n\n\n\nHave fun, and thank you for helping us!"));
                SendData(AchievementDataListComposer.Compose(AchievementManager.Achievements.Values.ToList()));

                // Unknown packet 1
                // Thought: Navigator config?
                ServerMessage UnkMessage2 = new ServerMessage(290);
                UnkMessage2.AppendInt32(1);
                UnkMessage2.AppendInt32(0);
                SendData(UnkMessage2);

                // Unknown packet 2
                // Thought: durrrrrrrrr
                ServerMessage UnkMessage3 = new ServerMessage(517);
                UnkMessage3.AppendInt32(1);
                SendData(UnkMessage3);

                // Unknown packet 3
                // No idea.
                ServerMessage UnkMessage4 = new ServerMessage(628);
                UnkMessage4.AppendInt32(1);
                UnkMessage4.AppendInt32(0);
                UnkMessage4.AppendInt32(2971);
                SendData(UnkMessage4);

                SendData(ClientConfigComposer.Compose(CharacterInfo.ConfigVolume, false));

                if (HasRight("moderation_tool"))
                {
                    SendData(ModerationToolComposer.Compose(this, ModerationPresets.UserMessagePresets,
                        ModerationPresets.UserActionPresets, ModerationPresets.RoomMessagePresets));

                    foreach (ModerationTicket ModTicket in ModerationTicketManager.ActiveTickets)
                    {
                        SendData(ModerationTicketComposer.Compose(ModTicket));
                    }
                }

                MessengerHandler.MarkUpdateNeeded(this, 0, true);
            }
        }
Exemplo n.º 11
0
 public static void SendDataToAllModerators(ServerMessage Message)
 {
     SessionManager.BroadcastPacket(Message, "moderation_tickets");
 }
Exemplo n.º 12
0
 public static void BroadcastPacket(ServerMessage Message, string RequiredRight)
 {
     BroadcastPacket(Message.GetBytes(), RequiredRight);
 }
Exemplo n.º 13
0
 public static void BroadcastPacket(ServerMessage Message)
 {
     BroadcastPacket(Message.GetBytes(), string.Empty);
 }
Exemplo n.º 14
0
 internal void BroadCastMessage(ServerMessage serverMessage)
 {
     throw new NotImplementedException();
 }