예제 #1
0
파일: NewsList.cs 프로젝트: Mofsy/jinxbot
        public NewsList(BattleNetClient client)
            : this()
        {
            m_client = client;

            m_client.ServerNews += new BNSharp.BattleNet.ServerNewsEventHandler(m_client_ServerNews);
        }
예제 #2
0
 public void UnregisterPackets(BattleNetClient client)
 {
     if (m_registered)
     {
         m_conn.UnregisterPackets(client);
         m_registered = false;
     }
 }
예제 #3
0
        public ChannelList(BattleNetClient client)
            : this()
        {
            m_client = client;

            ProcessEventSetup();

            m_resourceProvider = ProfileResourceProvider.GetForClient(client);
        }
예제 #4
0
 public void RegisterPackets(BattleNetClient client)
 {
     Product clientProduct = Product.GetByProductCode(client.Settings.Client);
     if (object.ReferenceEquals(clientProduct, Product.Diablo2Retail) || object.ReferenceEquals(clientProduct, Product.Diablo2Expansion))
     {
         m_registered = true;
         m_conn.RegisterPackets(client);
     }
 }
예제 #5
0
        /// <summary>
        /// Creates a new <see>ChatDocument</see> to handle the specified client.
        /// </summary>
        /// <param name="client">The client to handle.</param>
        public ChatDocument(BattleNetClient client)
            : this()
        {
            m_client = client;
            m_prp = ProfileResourceProvider.GetForClient(client);
            m_profile = client.Settings as ClientProfile;

            SetupEventRegistration();
        }
예제 #6
0
 public FriendsList(BattleNetClient client)
     : this()
 {
     client.FriendListReceived += new FriendListReceivedEventHandler(client_FriendListReceived);
     client.FriendMoved += new FriendMovedEventHandler(client_FriendMoved);
     client.FriendAdded += new FriendAddedEventHandler(client_FriendAdded);
     client.FriendRemoved += new FriendRemovedEventHandler(client_FriendRemoved);
     client.FriendUpdated += new FriendUpdatedEventHandler(client_FriendUpdated);
 }
예제 #7
0
        /// <summary>
        /// Unregisters a profile and cleans up its resources.
        /// </summary>
        /// <param name="client">The client to unregister.</param>
        public static void UnregisterProvider(BattleNetClient client)
        {
            if (!s_providers.ContainsKey(client))
                return;

            ProfileResourceProvider provider = s_providers[client];
            s_providers.Remove(client);

            provider.Dispose();
        }
예제 #8
0
파일: ClanList.cs 프로젝트: Mofsy/jinxbot
        public ClanList(BattleNetClient client)
            : this()
        {
            m_client = client;

            m_prp = ProfileResourceProvider.GetForClient(client);

            client.ClanMemberListReceived += new ClanMemberListEventHandler(client_ClanMemberListReceived);
            client.ClanMembershipReceived += new ClanMembershipEventHandler(client_ClanMembershipReceived);
        }
예제 #9
0
        private ProfileDocument(BattleNetClient client)
            : this()
        {
            m_client = client;
            this.Text = this.TabText = (client.Settings as ClientProfile).ProfileName;

            if (client.Settings.Client == Product.StarcraftRetail.ProductCode || client.Settings.Client == Product.StarcraftBroodWar.ProductCode 
                || client.Settings.Client == Product.Warcraft3Retail.ProductCode || client.Settings.Client == Product.Warcraft3Expansion.ProductCode)
            {
                //WardenPacketHandler module = new WardenPacketHandler(client);
                //m_client.WardenHandler = module;
            }

            client.EventExceptionThrown += new EventExceptionEventHandler(client_EventExceptionThrown);

            m_chat = new ChatDocument(client);
            m_chat.Text = "Main chat window (Disconnected)";
            m_chat.Show(this.dock);

            m_channel = new ChannelList(client);
            m_channel.Show(this.dock);

            IBattleNetSettings settings = client.Settings;
            string clientCode = settings.Client;
            if (clientCode.Equals(Product.Warcraft3Retail.ProductCode, StringComparison.Ordinal) ||
                clientCode.Equals(Product.Warcraft3Expansion.ProductCode, StringComparison.Ordinal))
            {
                m_friends = new FriendsList(client);
                m_friends.Show(this.dock);

                m_clan = new ClanList(client);
                m_clan.Show(this.dock);

                m_news = new NewsList(client);
                m_news.Show(this.dock);
                m_news.DockState = DockState.DockLeftAutoHide;
            }
            else if (clientCode.Equals(Product.StarcraftRetail.ProductCode, StringComparison.Ordinal) ||
                clientCode.Equals(Product.StarcraftBroodWar.ProductCode, StringComparison.Ordinal))
            {
                m_friends = new FriendsList(client);
                m_friends.Show(this.dock);
            }

            m_channel.Show();

            m_ssUri = m_chat.StylesheetUri;

            m_documents.Add(m_chat);

            client.RegisterWarcraftProfileReceivedNotification(Priority.Low, WarcraftProfileReceived);

            m_channel.VoidView = this.VoidView;
        }
예제 #10
0
        /// <summary>
        /// Registers a provider for the specified connection and returns the provider.
        /// </summary>
        /// <param name="client">The client connection to register.</param>
        /// <returns>A <see>ProfileResourceProvider</see> if the profile was newly registered; or <see langword="null" /> if the profile
        /// was already registered.</returns>
        public static ProfileResourceProvider RegisterProvider(BattleNetClient client)
        {
            ProfileResourceProvider provider = null;
            if (!s_providers.ContainsKey(client))
            {
                provider = new ProfileResourceProvider(client);
                s_providers.Add(client, provider);
            }

            return provider;
        }
예제 #11
0
        public ProfilePluginManager(ClientProfile profile, BattleNetClient client, ProfileDocument view)
        {
            m_profile = profile;
            m_client = client;
            m_view = view;

            m_clientPlugins = new List<ISingleClientPlugin>();
            m_multiClientPlugins = new List<IMultiClientPlugin>();
            m_clientPluginSettings = new Dictionary<ISingleClientPlugin, Dictionary<string, string>>();

            EnumeratePlugins(profile.PluginSettings);
        }
예제 #12
0
        public JinxBotClient(ClientProfile profile)
        {
            m_activePlugins = new Dictionary<ProfilePluginConfiguration, IJinxBotPlugin>();

            if (profile.SimulateClient)
                m_client = new SimulatedBattleNetClient(profile);
            else
                m_client = new BattleNetClient(profile);

            m_profile = profile;
            m_resourceProvider = ProfileResourceProvider.RegisterProvider(m_client);
            m_cmdTranslator = new CommandTranslator(this);

            bool hasSetCommandQueue = false;

            if (m_database == null)
                m_database = new JinxBotDefaultDatabase();

            // finally, initialize ui
            m_window = new ProfileDocument(this);

            // initialize plugins
            m_commandHandlers = new List<ICommandHandler>();
            foreach (ProfilePluginConfiguration pluginConfig in profile.PluginSettings)
            {
                hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, pluginConfig);
            }

            ProfilePluginConfiguration jsConfig = new ProfilePluginConfiguration
            {
                Assembly = "JinxBot.Plugins.Script.dll",
                Name = "JavaScript Plugin",
                Settings = new ProfilePluginSettingConfiguration[0],
                Type = "JinxBot.Plugins.Script.JinxBotJavaScriptPlugin"
            };
            hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, jsConfig);

            if (!hasSetCommandQueue)
            {
                m_client.CommandQueue = new TimedMessageQueue();
            }
        }
예제 #13
0
        public void HandleClientStartup(BattleNetClient client)
        {
            m_client = client;

            m_client.RegisterChannelDidNotExistNotification(Priority.Low, __ChannelDidNotExist);
            m_client.RegisterChannelListReceivedNotification(Priority.Low, __ChannelListReceived);
            m_client.RegisterChannelWasFullNotification(Priority.Low, __ChannelWasFull);
            m_client.RegisterChannelWasRestrictedNotification(Priority.Low, __ChannelWasRestricted);
            m_client.RegisterClientCheckFailedNotification(Priority.Low, __ClientCheckFailed);
            m_client.RegisterClientCheckPassedNotification(Priority.Low, __ClientCheckPassed);
            m_client.RegisterCommandSentNotification(Priority.Low, __CommandSent);
            m_client.RegisterConnectedNotification(Priority.Low, __Connected);
            m_client.RegisterDisconnectedNotification(Priority.Low, __Disconnected);
            m_client.RegisterEnteredChatNotification(Priority.Low, __EnteredChat);
            m_client.RegisterErrorNotification(Priority.Low, __Error);
            m_client.RegisterInformationNotification(Priority.Low, __Information);
            m_client.RegisterInformationReceivedNotification(Priority.Low, __InformationReceived);
            m_client.RegisterJoinedChannelNotification(Priority.Low, __JoinedChannel);
            m_client.RegisterLoginFailedNotification(Priority.Low, __LoginFailed);
            m_client.RegisterLoginSucceededNotification(Priority.Low, __LoginSucceeded);
            m_client.RegisterMessageSentNotification(Priority.Low, __MessageSent);
            m_client.RegisterServerBroadcastNotification(Priority.Low, __ServerBroadcast);
            m_client.RegisterServerErrorReceivedNotification(Priority.Low, __ServerErrorReceived);
            m_client.RegisterUserEmotedNotification(Priority.Low, __UserEmoted);
            m_client.RegisterUserFlagsChangedNotification(Priority.Low, __UserFlagsChanged);
            m_client.RegisterUserJoinedNotification(Priority.Low, __UserJoined);
            m_client.RegisterUserLeftNotification(Priority.Low, __UserLeft);
            m_client.RegisterUserShownNotification(Priority.Low, __UserShown);
            m_client.RegisterUserSpokeNotification(Priority.Low, __UserSpoke);
            m_client.RegisterWardentUnhandledNotification(Priority.Low, __WardenUnhandled);
            m_client.RegisterWhisperReceivedNotification(Priority.Low, __WhisperReceived);
            m_client.RegisterWhisperSentNotification(Priority.Low, __WhisperSent);

            if (!m_svc.LoginChannel(m_channelID, m_pwHash, client.Settings.Server))
            {
                MessageBox.Show("Unable to login channel.");
            }
        }
예제 #14
0
        /// <summary>
        /// Gets a <see>ProfileResourceProvider</see> for the specified client.
        /// </summary>
        /// <param name="client">The client for which to get the provider.</param>
        /// <returns>A <see>ProfileResourceProvider</see> instance if one was registered; otherwise <see langword="null" />.</returns>
        public static ProfileResourceProvider GetForClient(BattleNetClient client)
        {
            if (object.ReferenceEquals(null, client))
            {
                KeyValuePair<BattleNetClient, ProfileResourceProvider> prp = s_providers.FirstOrDefault();
                
                return prp.Value;
            }

            if (s_providers.ContainsKey(client))
                return s_providers[client];

            return null;
        }
예제 #15
0
 public static BaseEventArgs GetEmpty(BattleNetClient.ParseData eventData)
 {
     BaseEventArgs e = new BaseEventArgs();
     e.EventData = eventData;
     return e;
 }
예제 #16
0
        public void UnregisterEvents(IJinxBotClient profileClient)
        {
            m_bnet.UnregisterUserJoinedNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserShownNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserFlagsChangedNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserLeftNotification(Priority.High, user_Left);

            m_bnet = null;
            m_client = null;
            m_db = null;
        }
예제 #17
0
        public void RegisterEvents(IJinxBotClient profileClient)
        {
            m_client = profileClient;
            m_bnet = profileClient.Client;
            m_db = profileClient.Database;

            m_bnet.RegisterUserJoinedNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserShownNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserFlagsChangedNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserLeftNotification(Priority.High, user_Left);
        }
예제 #18
0
            public EventSink(BattleNetClient host)
            {
                Debug.Assert(host != null);

                m_host = host;
            }
예제 #19
0
파일: ChatLogger.cs 프로젝트: Mofsy/jinxbot
 public ChatLogger(BattleNetClient client)
 {
     
 }
예제 #20
0
 public BattleNetClientChannel(BattleNetClient source)
 {
     _namesToUsers     = new Dictionary <string, ChatUser>();
     _client           = source;
     _oldParseCallback = _client.RegisterParseCallback(BncsPacketId.ChatEvent, HandleChatEvent);
 }
예제 #21
0
파일: Program.cs 프로젝트: Mofsy/jinxbot
        private static async void MainThread()
        {
            console = new AsyncConsole(200, 300);
            console.InputForegroundColor = ConsoleColor.White;
            console.OutputBackgroundColor = ConsoleColor.Black;
            console.OutputForegroundColor = ConsoleColor.White;
            console.InputBackgroundColor = ConsoleColor.Black;
            console.WindowWidth = 200;
            console.Clear();

            var client = new BattleNetClient(_settings);

            client.Connected += Client_Connected;
            client.Disconnected += Client_Disconnected;
            client.ClientCheckPassed += client_ClientCheckPassed;
            client.ClientCheckFailed += client_ClientCheckFailed;
            client.LoginSucceeded += client_LoginSucceeded;
            client.LoginFailed += client_LoginFailed;
            client.AccountCreated += client_AccountCreated;
            client.AccountCreationFailed += client_AccountCreationFailed;

            client.Channel.UserJoined += Client_UserJoinedChannel;
            client.Channel.UserLeft += Client_UserLeftChannel;
            client.Channel.UserShown += Client_UserWasInChannel;
            client.Channel.UserSpoke += Client_UserSpoke;
            client.Channel.UserEmoted += Client_UserEmoted;
            client.Channel.NewChannelJoined += Channel_NewChannelJoined;

            client.ServerError += client_ServerError;
            client.ServerInformation += client_ServerInformation;
            client.Broadcast += client_Broadcast;
            client.WhisperReceived += client_WhisperReceived;
            client.WhisperSent += client_WhisperSent;
            client.ChannelListReceived += client_ChannelListReceived;

            client.ConnectAsync();

            string lastInput;
            do
            {
                lastInput = await console.ReadLineAsync();
                switch (lastInput)
                {
                    case "/clear":
                        console.Clear();
                        break;
                    case "/channel-list":
                    case "/cl":
                        if (_channel != null)
                        {
                            client_ChannelListReceived(client, _channel);
                        }
                        else
                        {
                            console.OutputForegroundColor = ConsoleColor.Red;
                            console.WriteLine("The channel list has not yet been received.");
                        }
                        break;
                    case "/quit":
                        client.Disconnect();
                        break;
                    default:
                        client.Send(lastInput);
                        break;
                }
            }
            while (lastInput != "/quit");

            _ended.Set();
        }
예제 #22
0
 /// <summary>
 /// Unregisters a client connection, halting tracking and decreasing the available buffer pool.
 /// </summary>
 /// <param name="client">The client connection being unregistered.</param>
 public static void UnregisterClient(BattleNetClient client)
 {
     s_activeClients.Remove(client);
     s_incoming.DecreaseBufferCount(INCOMING_BUFFERS_PER_CLIENT);
     s_outgoing.DecreaseBufferCount(OUTGOING_BUFFERS_PER_CLIENT);
 }
예제 #23
0
 public void HandleClientShutdown(BattleNetClient client)
 {
     m_client.UnregisterChannelDidNotExistNotification(Priority.Low, __ChannelDidNotExist);
     m_client.UnregisterChannelListReceivedNotification(Priority.Low, __ChannelListReceived);
     m_client.UnregisterChannelWasFullNotification(Priority.Low, __ChannelWasFull);
     m_client.UnregisterChannelWasRestrictedNotification(Priority.Low, __ChannelWasRestricted);
     m_client.UnregisterClientCheckFailedNotification(Priority.Low, __ClientCheckFailed);
     m_client.UnregisterClientCheckPassedNotification(Priority.Low, __ClientCheckPassed);
     m_client.UnregisterCommandSentNotification(Priority.Low, __CommandSent);
     m_client.UnregisterConnectedNotification(Priority.Low, __Connected);
     m_client.UnregisterDisconnectedNotification(Priority.Low, __Disconnected);
     m_client.UnregisterEnteredChatNotification(Priority.Low, __EnteredChat);
     m_client.UnregisterErrorNotification(Priority.Low, __Error);
     m_client.UnregisterInformationNotification(Priority.Low, __Information);
     m_client.UnregisterInformationReceivedNotification(Priority.Low, __InformationReceived);
     m_client.UnregisterJoinedChannelNotification(Priority.Low, __JoinedChannel);
     m_client.UnregisterLoginFailedNotification(Priority.Low, __LoginFailed);
     m_client.UnregisterLoginSucceededNotification(Priority.Low, __LoginSucceeded);
     m_client.RegisterMessageSentNotification(Priority.Low, __MessageSent);
     m_client.RegisterServerBroadcastNotification(Priority.Low, __ServerBroadcast);
     m_client.RegisterServerErrorReceivedNotification(Priority.Low, __ServerErrorReceived);
     m_client.RegisterUserEmotedNotification(Priority.Low, __UserEmoted);
     m_client.RegisterUserFlagsChangedNotification(Priority.Low, __UserFlagsChanged);
     m_client.RegisterUserJoinedNotification(Priority.Low, __UserJoined);
     m_client.RegisterUserLeftNotification(Priority.Low, __UserLeft);
     m_client.RegisterUserShownNotification(Priority.Low, __UserShown);
     m_client.RegisterUserSpokeNotification(Priority.Low, __UserSpoke);
     m_client.RegisterWardentUnhandledNotification(Priority.Low, __WardenUnhandled);
     m_client.RegisterWhisperReceivedNotification(Priority.Low, __WhisperReceived);
     m_client.RegisterWhisperSentNotification(Priority.Low, __WhisperSent);
 }
            public EventSink(BattleNetClient host)
            {
                Debug.Assert(host != null);

                m_host = host;
            }
예제 #25
0
 private ProfileResourceProvider(BattleNetClient client)
 {
     ClientProfile profile = client.Settings as ClientProfile;
     m_iconProvider = IconProviderFactory.GetProvider(profile.IconProviderType);
 }