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


C# Session.SendData方法代码示例

本文整理汇总了C#中Snowlight.Game.Sessions.Session.SendData方法的典型用法代码示例。如果您正苦于以下问题:C# Session.SendData方法的具体用法?C# Session.SendData怎么用?C# Session.SendData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Snowlight.Game.Sessions.Session的用法示例。


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

示例1: 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:fuding,项目名称:Snowlight,代码行数:29,代码来源:ModerationHandler.cs

示例2: HandleExchangeRedemption

        private static bool HandleExchangeRedemption(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData)
        {
            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:habb0,项目名称:Snowlight,代码行数:27,代码来源:ExchangeHandler.cs

示例3: 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:fuding,项目名称:Snowlight,代码行数:28,代码来源:ModerationHandler.cs

示例4: 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:habb0,项目名称:Snowlight,代码行数:8,代码来源:Global.cs

示例5: InitCrypto

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

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

示例6: HandleWired

        private static bool HandleWired(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event) {
            case ItemEventType.Interact:
                switch (Item.Definition.Behavior) {
                case ItemBehavior.WiredTrigger:
                    Session.SendData (WiredFurniTriggerComposer.Compose (Item, Instance));
                    break;

                case ItemBehavior.WiredEffect:
                    Session.SendData (WiredFurniActionComposer.Compose (Item, Instance));
                    break;
                }
                break;
            case ItemEventType.Placed:
                Item.WiredData = Instance.WiredManager.LoadWired (Item.Id, Item.Definition.BehaviorData);
                break;
            case ItemEventType.Removing:
                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) {
                    Instance.WiredManager.RemoveWired (Item.Id, MySqlClient);
                }

                Instance.WiredManager.DeRegisterWalkItem(Item.Id);
                break;
            case ItemEventType.UpdateTick:
                if (Item.Definition.Behavior == ItemBehavior.WiredTrigger) {
                    switch (WiredTypesUtil.TriggerFromInt (Item.Definition.BehaviorData)) {
                    case WiredTriggerTypes.periodically:
                        Instance.WiredManager.ExecuteActions (Item, null);
                        Item.RequestUpdate (Item.WiredData.Data2);
                        break;
                    case WiredTriggerTypes.at_given_time:
                        Instance.WiredManager.ExecuteActions (Item, null);
                        break;
                    }
                    return true;
                }
                Item.BroadcastStateUpdate (Instance);
                break;
            }
            return true;
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:42,代码来源:WiredHandler.cs

示例7: TradeAccept

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

            if (Instance == null)
            {
                return;
            }

            Trade Trade = Instance.TradeManager.GetTradeForUser(Session.CharacterId);

            if (Trade == null || !Trade.AcceptTrade(Trade.UserOne == Session.CharacterId))
            {
                return;
            }

            ServerMessage TradeAcceptState = TradeAcceptStateComposer.Compose(Session.CharacterId, true);
            ServerMessage TradeFinalizing = (Trade.TradeStage == TradeStage.Finalizing ? TradeFinalizingComposer.Compose()
                : null);

            Session.SendData(TradeAcceptState);

            if (TradeFinalizing != null)
            {
                Session.SendData(TradeFinalizing);
            }

            Session TargetSession = SessionManager.GetSessionByCharacterId(Trade.UserOne == Session.CharacterId ?
                Trade.UserTwo : Trade.UserOne);

            if (TargetSession != null)
            {
                TargetSession.SendData(TradeAcceptState);

                if (TradeFinalizing != null)
                {
                    TargetSession.SendData(TradeFinalizing);
                }
            }
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:40,代码来源:TradeHandler.cs

示例8: EnterRoom

        public static void EnterRoom(Session Session, RoomInstance Instance)
        {
            if (!Session.RoomAuthed || Session.RoomJoined || Session.AbsoluteRoomId != Instance.RoomId)
            {
                return;
            }

            Session.SendData(RoomUrlComposer.Compose("http://www.meth0d.org/snowlight"));
            Session.SendData(RoomEntryModelComposer.Compose(Instance.Model.Id, Instance.Info.Id));

            if (Instance.Info.Type == RoomType.Flat)
            {
                Dictionary<string, string> Decorations = Instance.Info.Decorations;

                foreach (KeyValuePair<string, string> Decoration in Decorations)
                {
                    Session.SendData(RoomDecorationComposer.Compose(Decoration.Key, Decoration.Value));
                }

                Session.SendData(RoomRatingInfoComposer.Compose((Session.RatedRoomsCache.HasRatedRoom(Instance.RoomId) || Instance.CheckUserRights(Session, true)) ? Instance.Info.Score : -1));
                Session.SendData(RoomEventInfoComposer.Compose(Instance.Event));
            }
        }
开发者ID:DaimOwns,项目名称:Snowlight,代码行数:23,代码来源:RoomHandler.cs

示例9: ActivateEffect

        private static void ActivateEffect(Session Session, ClientMessage Message)
        {
            AvatarEffect Effect = Session.AvatarEffectCache.GetEffect(Message.PopWiredInt32(), false, true);

            // If we do not have an effect that needs activating OR if we already have an effect
            // of this sort which IS activated, stop.
            if (Effect == null || Session.AvatarEffectCache.HasEffect(Effect.SpriteId, true))
            {
                return;
            }

            Effect.Activate();
            Session.SendData(UserEffectActivatedComposer.Compose(Effect));
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:14,代码来源:Inventory.cs

示例10: GetIgnoredUsers

        private static void GetIgnoredUsers(Session Session, ClientMessage Message)
        {
            ReadOnlyCollection<uint> IgnoredUsers = Session.IgnoreCache.List;
            List<string> Names = new List<string>();

            foreach (uint IgnoredUser in IgnoredUsers)
            {
                string Name = CharacterResolverCache.GetNameFromUid(IgnoredUser);

                if (Name != "Unknown User" && !Names.Contains(Name))
                {
                    Names.Add(Name);
                }
            }

            Session.SendData(IgnoredUserListComposer.Compose(Names));
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:17,代码来源:Handshake.cs

示例11: GetPopularRooms

        private static void GetPopularRooms(Session Session, ClientMessage Message)
        {
            ServerMessage Response = TryGetResponseFromCache(0, Message);

            if (Response != null)
            {
                Session.SendData(Response);
                return;
            }

            int Category = -1;
            int.TryParse(Message.PopString(), out Category);

            IEnumerable<RoomInstance> Rooms =
                (from RoomInstance in RoomManager.RoomInstances
                 where RoomInstance.Value.Info.Type == RoomType.Flat &&
                    RoomInstance.Value.CachedNavigatorUserCount > 0 &&
                    (Category == -1 || RoomInstance.Value.Info.CategoryId == Category)
                 orderby RoomInstance.Value.CachedNavigatorUserCount descending
                 select RoomInstance.Value).Take(50);

            Response = NavigatorRoomListComposer.Compose(Category, 1, string.Empty, Rooms.ToList());
            AddToCacheIfNeeded(0, Message, Response);
            Session.SendData(Response);
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:25,代码来源:Navigator.cs

示例12: GetOfficialRooms

        private static void GetOfficialRooms(Session Session, ClientMessage Message)
        {
            ServerMessage Response = TryGetResponseFromCache(0, Message);

            if (Response != null)
            {
                Session.SendData(Response);
                return;
            }

            Response = NavigatorOfficialRoomsComposer.Message(mOfficialItems);
            AddToCacheIfNeeded(0, Message, Response);
            Session.SendData(Response);
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:14,代码来源:Navigator.cs

示例13: GetFriendsRooms

        private static void GetFriendsRooms(Session Session, ClientMessage Message)
        {
            ServerMessage Response = TryGetResponseFromCache(Session.CharacterId, Message);

            if (Response != null)
            {
                Session.SendData(Response);
                return;
            }

            List<RoomInfo> Rooms = new List<RoomInfo>();
            ReadOnlyCollection<uint> Friends = Session.MessengerFriendCache.Friends;

            if (Friends.Count > 0)
            {
                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    StringBuilder QueryBuilder = new StringBuilder("SELECT * FROM rooms WHERE ");

                    int i = 0;

                    foreach (uint FriendId in Friends)
                    {
                        if (i >= 1)
                        {
                            QueryBuilder.Append("OR ");
                        }

                        QueryBuilder.Append("owner_id = " + FriendId + " ");
                        i++;
                    }

                    QueryBuilder.Append("ORDER BY current_users DESC LIMIT 50");

                    DataTable Table = MySqlClient.ExecuteQueryTable(QueryBuilder.ToString());

                    foreach (DataRow Row in Table.Rows)
                    {
                        Rooms.Add(RoomInfoLoader.GenerateRoomInfoFromRow(Row));
                    }
                }
            }

            Response = NavigatorRoomListComposer.Compose(0, 3, string.Empty, Rooms);
            AddToCacheIfNeeded(Session.CharacterId, Message, Response);
            Session.SendData(Response);
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:47,代码来源:Navigator.cs

示例14: GetEventRooms

        private static void GetEventRooms(Session Session, ClientMessage Message)
        {
            ServerMessage Response = TryGetResponseFromCache(0, Message);

            if (Response != null)
            {
                Session.SendData(Response);
                return;
            }

            int Category = -1;
            int.TryParse(Message.PopString(), out Category);

            IEnumerable<RoomInstance> Rooms =
                (from RoomInstance in RoomManager.RoomInstances
                 where (RoomInstance.Value.HasOngoingEvent &&
                     (Category == -1 || RoomInstance.Value.Event.CategoryId == Category))
                 orderby RoomInstance.Value.Event.TimestampStarted descending
                 select RoomInstance.Value).Take(50);

            Response = NavigatorRoomListComposer.Compose(Category, 12, string.Empty, Rooms.ToList(), true);
            AddToCacheIfNeeded(0, Message, Response);
            Session.SendData(Response);
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:24,代码来源:Navigator.cs

示例15: GetCategories

        private static void GetCategories(Session Session, ClientMessage Message)
        {
            ServerMessage Response = TryGetResponseFromCache(0, Message);

            if (Response != null)
            {
                Session.SendData(Response);
                return;
            }

            Response = NavigatorFlatCategoriesComposer.Compose(mFlatCategories);
            AddToCacheIfNeeded(0, Message, Response);
            Session.SendData(Response);
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:14,代码来源:Navigator.cs


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