/// <summary> /// /// </summary> /// <param name="local"></param> /// <param name="distant"></param> public AbstractEntityExchange(ExchangeTypeEnum type, AbstractEntity local, AbstractEntity distant) : base(type) { m_local = local; m_distant = distant; if (m_local.Inventory == null || m_distant.Inventory == null) { Logger.Debug("EntityExchange : exchange with an entity that hasnt an inventory."); } m_exchangedItems = new Dictionary <long, Dictionary <long, int> >() { { m_local.Id, new Dictionary <long, int>() }, { m_distant.Id, new Dictionary <long, int>() }, }; m_exchangedKamas = new Dictionary <long, long>() { { m_local.Id, 0 }, { m_distant.Id, 0 }, }; m_validated = new Dictionary <long, bool>() { { m_local.Id, false }, { m_distant.Id, false }, }; }
public static void CreateProducerRegistration(string solutionDirectory, string srcDirectory, Producer producer, string projectBaseName) { var className = $@"{producer.EndpointRegistrationMethodName}Registration"; var classPath = ClassPathHelper.WebApiProducersServiceExtensionsClassPath(srcDirectory, $"{className}.cs", projectBaseName); if (!Directory.Exists(classPath.ClassDirectory)) { Directory.CreateDirectory(classPath.ClassDirectory); } if (File.Exists(classPath.FullClassPath)) { throw new FileAlreadyExistsException(classPath.FullClassPath); } using FileStream fs = File.Create(classPath.FullClassPath); var data = ""; if (ExchangeTypeEnum.FromName(producer.ExchangeType) == ExchangeTypeEnum.Direct || ExchangeTypeEnum.FromName(producer.ExchangeType) == ExchangeTypeEnum.Topic) { data = GetDirectOrTopicProducerRegistration(solutionDirectory, classPath.ClassNamespace, className, producer); } else { data = GetFanoutProducerRegistration(solutionDirectory, classPath.ClassNamespace, className, producer); } fs.Write(Encoding.UTF8.GetBytes(data)); }
public static void SendExchangeRequestedTradeMessage(IPacketReceiver client, ExchangeTypeEnum type, Character source, Character target) { client.Send(new ExchangeRequestedTradeMessage( (sbyte)type, source.Id, target.Id)); }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="skill"></param> /// <param name="type"></param> public CraftPlanExchange(CharacterEntity character, CraftPlan plan, JobSkill skill, ExchangeTypeEnum type = ExchangeTypeEnum.EXCHANGE_CRAFTPLAN) : base(type) { m_caseItems = new Dictionary<long, int>(); m_templateQuantity = new Dictionary<int, long>(); m_plan = plan; Character = character; Skill = (CraftSkill)skill; Job = Character.CharacterJobs.GetJob(skill.Id); MaxCase = Job.CraftMaxCase; }
public static void HandleExchangePlayerRequestMessage(WorldClient client, ExchangePlayerRequestMessage message) { ExchangeTypeEnum exchangeType = (ExchangeTypeEnum)message.exchangeType; if (exchangeType != ExchangeTypeEnum.PLAYER_TRADE) { InventoryHandler.SendExchangeErrorMessage(client, ExchangeErrorEnum.REQUEST_IMPOSSIBLE); } else { Character character = Singleton <World> .Instance.GetCharacter((int)message.target); if (character == null) { InventoryHandler.SendExchangeErrorMessage(client, ExchangeErrorEnum.BID_SEARCH_ERROR); } else { if (character.Map.Id != client.Character.Map.Id) { InventoryHandler.SendExchangeErrorMessage(client, ExchangeErrorEnum.REQUEST_CHARACTER_TOOL_TOO_FAR); } else { if (character.IsInRequest() || character.IsTrading()) { InventoryHandler.SendExchangeErrorMessage(client, ExchangeErrorEnum.REQUEST_CHARACTER_OCCUPIED); } else { if (character.IsAway) { InventoryHandler.SendExchangeErrorMessage(client, ExchangeErrorEnum.REQUEST_CHARACTER_OCCUPIED); } else { if (!client.Character.Map.AllowExchangesBetweenPlayers) { InventoryHandler.SendExchangeErrorMessage(client, ExchangeErrorEnum.REQUEST_IMPOSSIBLE); } else { PlayerTradeRequest playerTradeRequest = new PlayerTradeRequest(client.Character, character); client.Character.OpenRequestBox(playerTradeRequest); character.OpenRequestBox(playerTradeRequest); playerTradeRequest.Open(); } } } } } } }
public static string GetDirectOrTopicConsumerRegistration(string classNamespace, string className, Consumer consumer, string lazyText, string quorumText, string consumerFeatureUsing) { var exchangeType = ExchangeTypeEnum.FromName(consumer.ExchangeType) == ExchangeTypeEnum.Direct ? "ExchangeType.Direct" : "ExchangeType.Topic"; return(@$ "namespace {classNamespace}; using MassTransit; using MassTransit.RabbitMqTransport; using RabbitMQ.Client; using {consumerFeatureUsing};
public static string GetDirectOrTopicProducerRegistration(string solutionDirectory, string classNamespace, string className, Producer producer) { var exchangeType = ExchangeTypeEnum.FromName(producer.ExchangeType) == ExchangeTypeEnum.Direct ? "ExchangeType.Direct" : "ExchangeType.Topic"; var messagesClassPath = ClassPathHelper.MessagesClassPath(solutionDirectory, ""); return(@$ "namespace {classNamespace}; using MassTransit; using MassTransit.RabbitMqTransport; using {messagesClassPath.ClassNamespace}; using RabbitMQ.Client;
public void ExchangeDeclare(string exchangeName, ExchangeTypeEnum type, bool isDelay) { if (isDelay) { Channel.ExchangeDeclare(exchangeName, "x-delayed-message", true, false, new Dictionary <string, object>() { { "x-delayed-type", GetExchangeTypeName(type) } }); } else { Channel.ExchangeDeclare(exchangeName, GetExchangeTypeName(type), true, false, null); } }
private static string GetExchangeTypeName(ExchangeTypeEnum type) { switch (type) { case ExchangeTypeEnum.direct: return(RabbitMQ.Client.ExchangeType.Direct); case ExchangeTypeEnum.fanout: return(RabbitMQ.Client.ExchangeType.Fanout); case ExchangeTypeEnum.topic: return(RabbitMQ.Client.ExchangeType.Topic); } throw new NotSupportedException(); }
/// <summary> /// /// </summary> /// <param name="exchangeType"></param> /// <returns></returns> public override bool CanBeExchanged(ExchangeTypeEnum exchangeType) { switch (exchangeType) { case ExchangeTypeEnum.EXCHANGE_NPC: return(Rewards.Count > 0); case ExchangeTypeEnum.EXCHANGE_SHOP: return(ShopItems.Count > 0); case ExchangeTypeEnum.EXCHANGE_AUCTION_HOUSE_BUY: case ExchangeTypeEnum.EXCHANGE_AUCTION_HOUSE_SELL: return(AuctionHouse != null); } return(false); }
/// <summary> /// 添加默认设置项 /// </summary> /// <param name="channel"></param> /// <param name="exchange_name"></param> /// <param name="exchange_type"></param> /// <param name="is_delay"></param> public static void X_ExchangeDeclare(this IModel channel, string exchange_name, ExchangeTypeEnum exchange_type, bool is_delay = false) { if (is_delay) { channel.ExchangeDeclare(exchange_name, "x-delayed-message", true, false, new Dictionary <string, object>() { ["x-delayed-type"] = exchange_type.ToString() }); } else { channel.ExchangeDeclare(exchange_name, exchange_type.ToString(), true, false, null); } }
/// <summary> /// 添加默认设置项 /// </summary> public static void ExchangeDeclare_(this IModel channel, string exchange_name, ExchangeTypeEnum exchange_type, bool durable = true, bool auto_delete = false, bool is_delay = false) { if (is_delay) { var args = new Dictionary <string, object>() { ["x-delayed-type"] = exchange_type.GetExchangeTypeName() }; channel.ExchangeDeclare(exchange_name, "x-delayed-message", durable, auto_delete, args); } else { channel.ExchangeDeclare(exchange_name, exchange_type.GetExchangeTypeName(), durable, auto_delete, null); } }
public static string GetExchangeTypeName(this ExchangeTypeEnum type) { switch (type) { case ExchangeTypeEnum.direct: return(ExchangeType.Direct); case ExchangeTypeEnum.fanout: return(ExchangeType.Fanout); case ExchangeTypeEnum.topic: return(ExchangeType.Topic); case ExchangeTypeEnum.headers: return(ExchangeType.Headers); } throw new NotSupportedException(); }
private string GetExchangeTypeString(ExchangeTypeEnum typeEnum) { switch (typeEnum) { case ExchangeTypeEnum.Direct: return("direct"); case ExchangeTypeEnum.Fanout: return("fanout"); case ExchangeTypeEnum.Topic: return("topic"); default: return("fanout"); } }
public static void CreateConsumerRegistration(string solutionDirectory, Consumer consumer, string projectBaseName) { var className = $@"{consumer.EndpointRegistrationMethodName}Registration"; var classPath = ClassPathHelper.WebApiConsumersServiceExtensionsClassPath(solutionDirectory, $"{className}.cs", projectBaseName); var consumerFeatureClassPath = ClassPathHelper.ConsumerFeaturesClassPath(solutionDirectory, $"{consumer.ConsumerName}.cs", consumer.DomainDirectory, projectBaseName); if (!Directory.Exists(classPath.ClassDirectory)) { Directory.CreateDirectory(classPath.ClassDirectory); } if (File.Exists(classPath.FullClassPath)) { throw new FileAlreadyExistsException(classPath.FullClassPath); } var quorumText = consumer.IsQuorum ? $@" // a replicated queue to provide high availability and data safety. available in RMQ 3.8+ re.SetQuorumQueue();" : ""; var lazyText = consumer.IsLazy ? $@" // enables a lazy queue for more stable cluster with better predictive performance. // Please note that you should disable lazy queues if you require really high performance, if the queues are always short, or if you have set a max-length policy. re.SetQueueArgument(""declare"", ""lazy"");" : ""; //re.Lazy = true;" : ""; using FileStream fs = File.Create(classPath.FullClassPath); var data = ""; if (ExchangeTypeEnum.FromName(consumer.ExchangeType) == ExchangeTypeEnum.Direct || ExchangeTypeEnum.FromName(consumer.ExchangeType) == ExchangeTypeEnum.Topic) { data = GetDirectOrTopicConsumerRegistration(classPath.ClassNamespace, className, consumer, lazyText, quorumText, consumerFeatureClassPath.ClassNamespace); } else { data = GetFanoutConsumerRegistration(classPath.ClassNamespace, className, consumer, lazyText, quorumText, consumerFeatureClassPath.ClassNamespace); } fs.Write(Encoding.UTF8.GetBytes(data)); }
public static void CreateExchange(this IModel channel, string exchange, ExchangeTypeEnum exchange_type, ExchangeOption option) { if (option == null) { throw new ArgumentNullException($"{nameof(CreateExchange)}.{nameof(option)}"); } option.Args = option.Args ?? new Dictionary <string, object>(); var exchange_type_name = exchange_type.GetExchangeTypeName(); if (exchange_type == ExchangeTypeEnum.delay) { option.Args["x-delayed-type"] = exchange_type_name; } channel.ExchangeDeclare(exchange: exchange, type: exchange_type_name, durable: option.Durable, autoDelete: option.AutoDelete, arguments: option.Args); }
public RabbitMqConsumerBase(IModel channel, string consumer_name, string exchange_name, string queue_name, string route_key, ExchangeTypeEnum exchangeType, bool persistent, bool ack, ushort concurrency_size, bool delay) { this._channel = channel ?? throw new ArgumentNullException(nameof(channel)); this._exchange_name = exchange_name ?? throw new ArgumentNullException(nameof(exchange_name)); this._queue_name = queue_name ?? throw new ArgumentNullException(nameof(queue_name)); this._route_key = route_key ?? throw new ArgumentNullException(nameof(route_key)); this._consumer_name = consumer_name ?? throw new ArgumentNullException(nameof(consumer_name)); this._ack = ack; this._concurrency_size = concurrency_size; this._delay = delay; this._exchange_type = exchangeType; this._persistent = persistent; this.SetupQueue(); this._consumer = new EventingBasicConsumer(this._channel); this.SetUpConsumer(); }
public static string GetExchangeTypeString(ExchangeTypeEnum exchangeType) { string exchangeTypeString = ""; switch (exchangeType) { case ExchangeTypeEnum.Fanout: exchangeTypeString = ExchangeType.Fanout; break; case ExchangeTypeEnum.Direct: exchangeTypeString = ExchangeType.Direct; break; case ExchangeTypeEnum.Topic: exchangeTypeString = ExchangeType.Topic; break; default: exchangeTypeString = ExchangeType.Fanout; break; } return(exchangeTypeString); }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeBase"/> class. /// </summary> /// <param name="type"> /// The type. /// </param> protected ExchangeBase(ExchangeTypeEnum type) { appliesTo = new List <ExchangeTypeEnum> { type }; }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="storage"></param> /// <param name="type"></param> public StorageExchange(CharacterEntity character, StorageInventory storage, ExchangeTypeEnum type = ExchangeTypeEnum.EXCHANGE_STORAGE) : base(type) { Character = character; Storage = storage; }
/// <summary> /// The get exporter. /// </summary> /// <param name="type"> /// The type. /// </param> /// <returns> /// The /// <see> /// <cref>IEnumerable</cref> /// </see> /// . /// </returns> public IEnumerable <IExchange> GetExporter(ExchangeTypeEnum type) { return(exporters.Where(x => x.AppliesTo(type))); }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="npc"></param> public AuctionHouseExchange(ExchangeTypeEnum type, CharacterEntity character, NonPlayerCharacterEntity npc) : base(type) { Character = character; Npc = npc; }
/// <summary> /// /// </summary> /// <param name="type"></param> protected AbstractExchange(ExchangeTypeEnum type) { Type = type; }
/// <summary> /// /// </summary> /// <param name="exchangeType"></param> /// <returns></returns> public override bool CanBeExchanged(ExchangeTypeEnum exchangeType) { return(exchangeType == ExchangeTypeEnum.EXCHANGE_MERCHANT); }
/// <summary> /// /// </summary> /// <param name="exchangeType"></param> /// <returns></returns> public override bool CanBeExchanged(ExchangeTypeEnum exchangeType) { return exchangeType == ExchangeTypeEnum.EXCHANGE_MERCHANT; }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="storage"></param> public GameStorageExchangeAction(CharacterEntity character, StorageInventory storage, ExchangeTypeEnum type = ExchangeTypeEnum.EXCHANGE_STORAGE) : base(new StorageExchange(character, storage, type), character, null) { }
/// <summary> /// /// </summary> /// <param name="exchangeType"></param> /// <returns></returns> public virtual bool CanBeExchanged(ExchangeTypeEnum exchangeType) { return(!HasEntityRestriction(EntityRestrictionEnum.RESTRICTION_CANT_EXCHANGE) && (CurrentAction == null || CurrentAction.IsFinished)); }
/// <summary> /// /// </summary> /// <param name="exchangeType"></param> /// <returns></returns> public virtual bool CanBeExchanged(ExchangeTypeEnum exchangeType) { return !HasEntityRestriction(EntityRestrictionEnum.RESTRICTION_CANT_EXCHANGE) && (CurrentAction == null || CurrentAction.IsFinished); }
/// <summary> /// The type to. /// </summary> /// <param name="type"> /// The type. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool AppliesTo(ExchangeTypeEnum type) { return(appliesTo.Contains(type)); }
public Topic(ExchangeTypeEnum type) { exchangeType = type; politeness = 6; }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="skill"></param> /// <param name="type"></param> public CraftPlanExchange(CharacterEntity character, CraftPlan plan, JobSkill skill, ExchangeTypeEnum type = ExchangeTypeEnum.EXCHANGE_CRAFTPLAN) : base(type) { m_caseItems = new Dictionary <long, int>(); m_templateQuantity = new Dictionary <int, long>(); m_plan = plan; Character = character; Skill = (CraftSkill)skill; Job = Character.CharacterJobs.GetJob(skill.Id); MaxCase = Job.CraftMaxCase; }
public static List<WorldClient> GetOnlineClientsExchanging(ExchangeTypeEnum exchange) { return WorldServer.Instance.GetAllClientsOnline().FindAll(x => x.Character != null && x.Character.ExchangeType != null && x.Character.ExchangeType == exchange); }
public static List <WorldClient> GetOnlineClientsExchanging(ExchangeTypeEnum exchange) { return(WorldServer.Instance.GetAllClientsOnline().FindAll(x => x.Character != null && x.Character.ExchangeType != null && x.Character.ExchangeType == exchange)); }
public Stock(string stockName, ExchangeTypeEnum exchange, string stockCode) { StockName = stockName; Exchange = exchange; StockCode = stockCode; }
public ExchangeCreateMessage(ExchangeTypeEnum ExchangeType, string Args = "") { this.ExchangeType = ExchangeType; this.Args = Args; }
/// <summary> /// /// </summary> /// <param name="exchangeType"></param> /// <returns></returns> public override bool CanBeExchanged(ExchangeTypeEnum exchangeType) { return base.CanBeExchanged(exchangeType) && (exchangeType == ExchangeTypeEnum.EXCHANGE_PLAYER || exchangeType == ExchangeTypeEnum.EXCHANGE_PERSONAL_SHOP_EDIT); }
/// <summary> /// /// </summary> /// <param name="local"></param> /// <param name="distant"></param> public AbstractEntityExchange(ExchangeTypeEnum type, AbstractEntity local, AbstractEntity distant) : base(type) { m_local = local; m_distant = distant; if (m_local.Inventory == null || m_distant.Inventory == null) { Logger.Debug("EntityExchange : exchange with an entity that hasnt an inventory."); } m_exchangedItems = new Dictionary<long, Dictionary<long, int>>() { { m_local.Id, new Dictionary<long, int>() }, { m_distant.Id, new Dictionary<long, int>() }, }; m_exchangedKamas = new Dictionary<long, long>() { { m_local.Id, 0}, { m_distant.Id, 0}, }; m_validated = new Dictionary<long, bool>() { { m_local.Id, false }, { m_distant.Id, false }, }; }