当前位置: 首页>>代码示例>>C#>>正文


C# Sessions.Session类代码示例

本文整理汇总了C#中Reality.Game.Sessions.Session的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Session类属于Reality.Game.Sessions命名空间,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleExchangeRedemption

        private static bool HandleExchangeRedemption(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event)
            {
                case ItemEventType.Interact:

                    int ItemValue = 0;
                    int.TryParse(Item.Flags, out ItemValue);

                    using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                    {
                        if (ItemValue != 0)
                        {
                            Session.CharacterInfo.UpdateCreditsBalance(MySqlClient, ItemValue);
                            Session.SendData(CreditsBalanceComposer.Compose(Session.CharacterInfo.CreditsBalance));
                        }

                        Item.RemovePermanently(MySqlClient);
                    }

                    Instance.TakeItem(Item.Id);
                    Instance.RegenerateRelativeHeightmap();
                    break;
            }

            return true;
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:27,代码来源:ExchangeHandler.cs

示例2: FinishSendHome

 public static bool FinishSendHome(Session Session, System.Timers.Timer Timer)
 {
     Timer.Dispose();
             Timer.Stop();
             Session.CharacterInfo.UpdateSentHome(0);
             return true;
 }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:7,代码来源:ChatCommands.cs

示例3: BanUser

        private static void BanUser(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            uint UserId = Message.PopWiredUInt32();
            string MessageText = Message.PopString();
            double Length = (Message.PopWiredInt32() * 3600);

            Session TargetSession = SessionManager.GetSessionByCharacterId(UserId);

            if (TargetSession == null || TargetSession.HasRight("moderation_tool"))
            {
                Session.SendData(NotificationMessageComposer.Compose("This user is not online or you do not have permission to ban them.\nPlease use housekeeping to ban users that are offline."));
                return;
            }

            SessionManager.StopSession(TargetSession.Id);

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                ModerationBanManager.BanUser(MySqlClient, UserId, MessageText, Session.CharacterId, Length);
                ModerationLogs.LogModerationAction(MySqlClient, Session, "Banned user",
                    "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") for " +
                    Length + " hours: '" + MessageText + "'");
            }
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:29,代码来源:ModerationHandler.cs

示例4: ApplyEffect

        private static void ApplyEffect(Session Session, ClientMessage Message)
        {
            int EffectSpriteId = Message.PopWiredInt32();

            if (EffectSpriteId < 0)
            {
                EffectSpriteId = 0;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                return;
            }

            RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId);

            if (Actor == null || (EffectSpriteId != 0 && !Session.AvatarEffectCache.HasEffect(EffectSpriteId, true)))
            {
                return;
            }

            Actor.ApplyEffect(EffectSpriteId);
            Session.CurrentEffect = EffectSpriteId;
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:26,代码来源:Inventory.cs

示例5: SubmitAnswer

        private static void SubmitAnswer(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                return;
            }

            RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId);

            if (Actor == null)
            {
                return;
            }

            int AnswerId = Message.PopWiredInt32();

            lock (mInfobusQuestions)
            {
                if (mInfobusQuestions.ContainsKey(Instance.RoomId))
                {
                    mInfobusQuestions[Instance.RoomId].SubmitAnswer(Actor.Id, AnswerId);
                }
            }
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:26,代码来源:InfobusManager.cs

示例6: HandleSwitch

        private static bool HandleSwitch(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            if (Event != ItemEventType.Interact)
            {
                return true;
            }
            RoomActor actor = Instance.GetActor(Session.CharacterId);
            if (actor == null)
            {
                return true;
            }

            foreach (Item item in Instance.GetFloorItems())
            {
                if (item.Definition.Behavior != ItemBehavior.WiredTrigger || WiredTypesUtil.TriggerFromInt(item.Definition.BehaviorData) != WiredTriggerTypes.state_changed)
                {
                    continue;
                }

                String[] Selected = item.WiredData.Data1.Split('|');

                if (Selected.Contains(Item.Id.ToString()))
                {
                    Instance.WiredManager.ExecuteActions(item, actor);
                }
            }
            return true;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:28,代码来源:WiredHandler.cs

示例7: Compose

        public static ServerMessage Compose(Session Session, ReadOnlyCollection<Achievement> Achievements)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.ACHIEVEMENTS_LIST);
            Message.AppendInt32(Achievements.Count);

            foreach (Achievement Achievement in Achievements)
            {
                UserAchievement UserData = Session.AchievementCache.GetAchievementData(Achievement.GroupName);
                int TargetLevel = (UserData != null ? UserData.Level + 1 : 1);
                int TotalLevels = Achievement.Levels.Count;

                if (TargetLevel > TotalLevels)
                {
                    TargetLevel = TotalLevels;
                }

                AchievementLevel TargetLevelData = Achievement.Levels[TargetLevel];

                Message.AppendUInt32(Achievement.Id);                                                           // Unknown (ID?)
                Message.AppendInt32(TargetLevel);                                                   // Target level
                Message.AppendStringWithBreak(Achievement.GroupName + TargetLevel);                 // Target name/desc/badge
                Message.AppendInt32(TargetLevelData.Requirement);                                   // Progress req/target
                Message.AppendInt32(TargetLevelData.PixelReward);                                   // Pixel reward
                Message.AppendInt32(TargetLevelData.PointsReward);                                  // Unknown(??)
                Message.AppendInt32(UserData != null ? UserData.Progress : 0);                      // Current progress
                Message.AppendBoolean(UserData != null ? (UserData.Level >= TotalLevels) : false);  // Set 100% completed(??)
                Message.AppendStringWithBreak(Achievement.Category);                                // Category
                Message.AppendInt32(TotalLevels);                                                   // Total amount of levels
            }

            return Message;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:32,代码来源:AchievementListComposer.cs

示例8: Compose

        public static ServerMessage Compose(Session Session, Dictionary<int, CatalogPage> Pages)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.CATALOG_INDEX);
            SerializePage(Message, Pages[-1], CalcTreeSize(Session, Pages, -1));

            foreach (CatalogPage Page in Pages.Values)
            {
                if (Page.ParentId != -1 || (Page.RequiredRight.Length > 0 && !Session.HasRight(Page.RequiredRight)))
                {
                    continue;
                }

                SerializePage(Message, Page, CalcTreeSize(Session, Pages, Page.Id));

                foreach (CatalogPage ChildPage in Pages.Values)
                {
                    if (ChildPage.ParentId != Page.Id || (ChildPage.RequiredRight.Length > 0 && !Session.HasRight(ChildPage.RequiredRight)))
                    {
                        continue;
                    }

                    SerializePage(Message, ChildPage, 0);
                }
            }

            return Message;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:27,代码来源:CatalogIndexComposer.cs

示例9: DeleteSticky

        private static void DeleteSticky(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session, true))
            {
                return;
            }

            Item Item = Instance.GetItem(Message.PopWiredUInt32());

            if (Item == null || Item.Definition.Behavior != ItemBehavior.StickyNote)
            {
                return;
            }

            if (Instance.TakeItem(Item.Id))
            {
                Instance.RegenerateRelativeHeightmap();

                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    Item.RemovePermanently(MySqlClient);
                }
            }
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:26,代码来源:RoomItemHandler.cs

示例10: AlertRoom

        private static void AlertRoom(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                Session.SendData(NotificationMessageComposer.Compose("Could not send room alert."));
                return;
            }

            int Unknown1 = Message.PopWiredInt32();
            int AlertMode = Message.PopWiredInt32();
            string AlertMessage = Message.PopString();
            bool IsCaution = AlertMode != 3;

            Instance.SendModerationAlert(AlertMessage, IsCaution);

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                ModerationLogs.LogModerationAction(MySqlClient, Session, "Sent room " + (IsCaution ? "caution" : "message"),
                    "Room " + Instance.Info.Name + " (ID " + Instance.RoomId + "): '" + AlertMessage + "'");
            }
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:28,代码来源:ModerationHandler.cs

示例11: HandleData

        public static void HandleData(Session Session, ClientMessage Message)
        {
            if (Session == null || Session.Stopped || Message == null)
            {
                return;
            }

            if (!mCallbacks.ContainsKey(Message.Id))
            {
                string text = System.IO.File.ReadAllText(Environment.CurrentDirectory + "\\packet-log.txt");
                Output.WriteLine("Unhandled packet: " + Message.Id + " (" + Constants.DefaultEncoding.GetString(Base64Encoding.EncodeUint32(Message.Id, 2)) + "), no suitable handler found.", OutputLevel.Warning);
                System.IO.StreamWriter file = new System.IO.StreamWriter(Environment.CurrentDirectory + "\\packet-log.txt");
                file.WriteLine(text + "Unhandled packet: " + Message.Id + " (" + Constants.DefaultEncoding.GetString(Base64Encoding.EncodeUint32(Message.Id, 2)) + "), no suitable handler found.",
                    OutputLevel.Notification + "\n\n");
                file.Close();
                return;
            }

            if (!Session.Authenticated && !mCallbacksWithoutAuthentication.Contains(Message.Id))
            {
                return;
            }

            mCallbacks[Message.Id].Invoke(Session, Message);
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:25,代码来源:DataRouter.cs

示例12: TryRedeemVoucher

        public static bool TryRedeemVoucher(SqlDatabaseClient MySqlClient, Session Session, string Code)
        {
            lock (mSyncRoot)
            {
                VoucherValueData ValueData = GetVoucherValue(Code);

                if (ValueData == null)
                {
                    return false;
                }

                if (ValueData.ValueCredits > 0)
                {
                    Session.CharacterInfo.UpdateCreditsBalance(MySqlClient, ValueData.ValueCredits);
                    Session.SendData(CreditsBalanceComposer.Compose(Session.CharacterInfo.CreditsBalance));
                }

                if (ValueData.ValuePixels > 0)
                {
                    Session.CharacterInfo.UpdateActivityPointsBalance(MySqlClient, ValueData.ValuePixels);
                    Session.SendData(ActivityPointsBalanceComposer.Compose(Session.CharacterInfo.ActivityPointsBalance, ValueData.ValuePixels));
                }

                if (ValueData.ValueFurni.Count > 0)
                {
                    Dictionary<int, List<uint>> NotifyItems = new Dictionary<int, List<uint>>();

                    foreach (uint ItemId in ValueData.ValueFurni)
                    {
                        Item Item = ItemFactory.CreateItem(MySqlClient, ItemId, Session.CharacterId, string.Empty,
                            string.Empty, 0, false);

                        if (Item != null)
                        {
                            int NotifyTabId = Item.Definition.Type == ItemType.WallItem ? 2 : 1;

                            Session.InventoryCache.Add(Item);
                            Session.NewItemsCache.MarkNewItem(MySqlClient, NotifyTabId, Item.Id);

                            if (!NotifyItems.ContainsKey(NotifyTabId))
                            {
                                NotifyItems.Add(NotifyTabId, new List<uint>());
                            }

                            NotifyItems[NotifyTabId].Add(Item.Id);
                        }
                    }

                    if (NotifyItems.Count > 0)
                    {
                        Session.SendData(InventoryRefreshComposer.Compose());
                        Session.SendData(InventoryNewItemsComposer.Compose(new Dictionary<int, List<uint>>(NotifyItems)));
                    }
                }

                MarkVoucherUsed(Code);
                return true;
            }
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:59,代码来源:VoucherManager.cs

示例13: OnClientDisconnectNotification

 private static void OnClientDisconnectNotification(Session Session, ClientMessage Message)
 {
     RoomInstance Instance1 = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);
     RoomActor Actor = Instance1.GetActorByReferenceId(Session.CharacterInfo.Id);
     Instance1.BroadcastMessage(RoomChatComposer.Compose(Actor.Id, "-- Logging out in 10 seconds! -- [DISCONNECED]", 0, ChatType.Shout));
     System.Threading.Thread.Sleep(10000);
     SessionManager.StopSession(Session.Id);
 }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:8,代码来源:Global.cs

示例14: OnSessionLatencyTest

        private static void OnSessionLatencyTest(Session Session, ClientMessage Message)
        {
            // Sesion timer sends a number to the server and expects it right back.
            // Maybe something to do with latency testing... or a keepalive?
            // Seems like a waste of bandwith since we're using pinging

            Session.SendData(LatencyTestResponseComposer.Compose(Message.PopWiredInt32()));
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:8,代码来源:Global.cs

示例15: InitCrypto

        private static void InitCrypto(Session Session, ClientMessage Message)
        {
            if (Session.Authenticated)
            {
                return;
            }

            Session.SendData(SessionParamsComposer.Compose());
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:9,代码来源:Handshake.cs


注:本文中的Reality.Game.Sessions.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。