Esempio n. 1
0
        /// <summary>
        /// 世界频道说话
        /// </summary>
        /// <param name="message">说话内容</param>
        bool SayToWorld(int userId, string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(message);
            }
            if (SystemConfig.Current.DefaultEncoding.GetByteCount(message) >= 256)
            {
                throw new ArgumentException("Message is too long. 255 byte is the limitation.");
            }

            bool result = false;
            User user   = AdminServer.TheInstance.SecurityManager.GetUser(userId);

            if (_server.IsConnected && _server.GameServiceState == GameServer.ServiceState.Running)
            {
                e2l_SayToWorld protocol = new e2l_SayToWorld();
                protocol.Message = message;
                result           = _server.SendMessage(protocol);
            }

            Security.LogSystem.TheInstance.WriteLog(
                userId,
                OpType.EXECUTE,
                _server.Id,
                string.Format(StringDef.LogMessageSayToWorld,
                              user == null ? userId.ToString() : user.UserName,
                              _server.Name,
                              message,
                              result ? StringDef.Success : StringDef.Fail)
                );
            return(result);
        }
Esempio n. 2
0
		/// <summary>
		/// 世界频道说话
		/// </summary>
		/// <param name="message">说话内容</param>
		bool SayToWorld(int userId,string message)
		{
			if (message == null)
				throw new ArgumentNullException(message);
			if (SystemConfig.Current.DefaultEncoding.GetByteCount(message) >= 256)
				throw new ArgumentException("Message is too long. 255 byte is the limitation.");

            bool result = false;
            User user = AdminServer.TheInstance.SecurityManager.GetUser(userId);

			if (_server.IsConnected && _server.GameServiceState == GameServer.ServiceState.Running)
			{
				e2l_SayToWorld protocol = new e2l_SayToWorld();
				protocol.Message = message;
                result = _server.SendMessage(protocol);
			}

            Security.LogSystem.TheInstance.WriteLog(
                userId,
                OpType.EXECUTE,
                _server.Id,
                string.Format(StringDef.LogMessageSayToWorld,
                            user == null ? userId.ToString() : user.UserName,
                            _server.Name,
                            message,
                            result ? StringDef.Success : StringDef.Fail)
            );
			return result;
		}