public void Load() { _plugin = new ChatPlugin(); var chat = new Chatm(); chat.OnMessage += _chatForm.OnMessage; _packets.Add(chat); _packets.Add(new Uotls()); BotTerminal.Instance.RegisterCommand(_plugin); foreach (var packet in _packets) { Player.Client.RegisterHandler(packet); } _chatForm = new Chat(); Thread mThread = new Thread(delegate() { _chatForm.ShowDialog(); }); mThread.SetApartmentState(ApartmentState.STA); mThread.Start(); }
public void Add(string commandType, ICommandHandle commandHandle) { _commandHandleDic.TryAdd(commandType, commandHandle); //if (_commandHandleDic.ContainsKey(commandType)) // _commandHandleDic.Add(commandType,commandHandle); }
/// <summary> /// 注册一个命令处理器 /// </summary> /// <param name="handle">命令处理器实例对象</param> public void RegisterCommandHandle(ICommandHandle handle) { if (handle != null) { //if (this.commandHandles == null) // this.commandHandles = new List<ICommandHandle>(); this.commandHandles.Add(handle); } }
public static Task WithCommandHandlerAsync <TCommand>(this IBusClient bus, ICommandHandle <TCommand> handler) where TCommand : ICommand => bus.SubscribeAsync <TCommand>( msg => handler.HandleAsync(msg), ctx => ctx.UseSubscribeConfiguration( cfg => cfg.FromDeclaredQueue( q => q.WithName(GetQueueName <TCommand>()) ) ) );
public void Subscribe <TCommand>(ICommandHandle <TCommand> commandHandle) where TCommand : ICommand { var type = typeof(TCommand); if (!commandHandles.ContainsKey(type)) { var hash = new HashSet <dynamic>(); hash.Add(commandHandle); commandHandles.Add(type, hash); } else { var hash = commandHandles[type]; if (!hash.Contains(commandHandle)) { hash.Add(commandHandle); } } }
public void UnregisterCommand(ICommandHandle command) => commands.Remove(command);
public void RegisterCommand(ICommandHandle command) => RegisterCommand(command, commands);
internal void RegisterHandle(ICommandHandle handle) { _handles.Add(handle); }