當前位置: 首頁>>代碼示例>>C#>>正文


C# Communication.ClientMessage類代碼示例

本文整理匯總了C#中Snowlight.Communication.ClientMessage的典型用法代碼示例。如果您正苦於以下問題:C# ClientMessage類的具體用法?C# ClientMessage怎麽用?C# ClientMessage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClientMessage類屬於Snowlight.Communication命名空間,在下文中一共展示了ClientMessage類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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

示例2: 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

示例3: 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:habb0,項目名稱:Snowlight,代碼行數:26,代碼來源:RoomItemHandler.cs

示例4: 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:habb0,項目名稱:Snowlight,代碼行數:26,代碼來源:InfobusManager.cs

示例5: 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:habb0,項目名稱:Snowlight,代碼行數:26,代碼來源:Inventory.cs

示例6: 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

示例7: InitCrypto

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

            Session.SendData(SessionParamsComposer.Compose());
        }
開發者ID:habb0,項目名稱:Snowlight,代碼行數:9,代碼來源:Handshake.cs

示例8: SsoLogin

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

            string Ticket = UserInputFilter.FilterString(Message.PopString());
            Session.TryAuthenticate(Ticket, Session.RemoteAddress.ToString());
        }
開發者ID:habb0,項目名稱:Snowlight,代碼行數:10,代碼來源:Handshake.cs

示例9: OnUserAgent

        private static void OnUserAgent(Session Session, ClientMessage Message)
        {
            string UserAgent = Message.PopString();

            if (UserAgent.Length > 2000)
            {
                UserAgent = UserAgent.Substring(0, 2000);
            }

            Session.UserAgent = UserAgent;
        }
開發者ID:habb0,項目名稱:Snowlight,代碼行數:11,代碼來源:Global.cs

示例10: TradeComplete

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

            if (Instance == null)
            {
                return;
            }

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

            if (Trade == null)
            {
                return;
            }

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

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

            if (Trade.TradeStage == TradeStage.Finalized)
            {
                Session User1 = (TargetSession.CharacterId == Trade.UserOne ? TargetSession : Session);
                Session User2 = (TargetSession.CharacterId == Trade.UserTwo ? TargetSession : Session);

                Trade.DeliverItems(User1, User2);

                Session.SendData(TradeFinalizedComposer.Compose());
                TargetSession.SendData(TradeFinalizedComposer.Compose());

                Instance.TradeManager.StopTradeForUser(Session.CharacterId);
                Instance.TradeManager.StopTradeForUser(TargetSession.CharacterId);

                RoomActor Actor1 = Instance.GetActorByReferenceId(Session.CharacterId);
                RoomActor Actor2 = Instance.GetActorByReferenceId(TargetSession.CharacterId);

                if (Actor1 != null)
                {
                    Actor1.RemoveStatus("trd");
                    Actor1.UpdateNeeded = true;
                }

                if (Actor2 != null)
                {
                    Actor2.RemoveStatus("trd");
                    Actor2.UpdateNeeded = true;
                }
            }
        }
開發者ID:habb0,項目名稱:Snowlight,代碼行數:53,代碼來源:TradeHandler.cs

示例11: 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

示例12: 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

示例13: OnClientConfig

        private static void OnClientConfig(Session Session, ClientMessage Message)
        {
            int Volume = Message.PopWiredInt32();
            bool Something = Message.PopWiredBoolean();

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

            if (Volume > 100)
            {
                Volume = 100;
            }

            Session.CharacterInfo.ConfigVolume = Volume;
        }
開發者ID:habb0,項目名稱:Snowlight,代碼行數:17,代碼來源:Global.cs

示例14: GetMoodlightInfo

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

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

            Item Item = Instance.MoodlightItem;

            if (Item == null)
            {
                return;
            }

            Session.SendData(MoodlightDataComposer.Compose(MoodlightData.GenerateFromFlags(Item.Flags)));
        }
開發者ID:habb0,項目名稱:Snowlight,代碼行數:18,代碼來源:RoomItemHandler.cs

示例15: HandleData

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

            if (!mCallbacks.ContainsKey(Message.Id))
            {
                Output.WriteLine("Unhandled packet: " + Message.Id + " (" + Constants.DefaultEncoding.GetString(Base64Encoding.EncodeUint32(Message.Id, 2)) + "), no suitable handler found.", OutputLevel.Warning);
                return;
            }

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

            mCallbacks[Message.Id].Invoke(Session, Message);
        }
開發者ID:habb0,項目名稱:Snowlight,代碼行數:20,代碼來源:DataRouter.cs


注:本文中的Snowlight.Communication.ClientMessage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。