コード例 #1
0
        public void Close()
        {
            m_client.Close();

            m_cmdTranslator.Dispose();
            m_cmdTranslator = null;

            foreach (ProfilePluginConfiguration config in m_activePlugins.Keys)
            {
                IJinxBotPlugin     plugin = m_activePlugins[config];
                IMultiClientPlugin mcp    = plugin as IMultiClientPlugin;
                if (mcp != null)
                {
                    mcp.RemoveClient(this);
                }

                ISingleClientPlugin scp = plugin as ISingleClientPlugin;
                if (scp != null)
                {
                    scp.UnregisterEvents(this);
                    scp.DestroyPluginWindows(this.ProfileDocument);
                }

                PluginFactory.ClosePluginInstance(config, plugin);

                JinxBotConfiguration.Instance.Save();
            }
        }
コード例 #2
0
 public void Disconnect()
 {
     if (m_connectingThread != null && m_connectingThread.IsAlive)
     {
         m_connectingThread.Abort();
     }
     m_client.Close();
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Mofsy/jinxbot
        static void Main(string[] args)
        {
            Console.WriteLine("Logging on with Starcraft; enter CD key.");
            string cdKey = Console.ReadLine().Trim();
            Console.WriteLine("Enter account name:");
            string acct = Console.ReadLine().Trim();
            Console.WriteLine("Enter account password for {0}:", acct);
            string password = Console.ReadLine().Trim();

            Settings set = new Settings() { CdKey1 = cdKey, Username = acct, Password = password, CdKeyOwner = acct };

            BattleNetClient client = new BattleNetClient(set);
            client.Connected += delegate { Console.WriteLine("--- CONNECTED"); };
            client.Error += new ErrorEventHandler(client_Error);
            client.EnteredChat += new EnteredChatEventHandler(client_EnteredChat);
            client.LoginSucceeded += new EventHandler(client_LoginSucceeded);
            client.LoginFailed += new LoginFailedEventHandler(client_LoginFailed);
            client.ServerBroadcast += new ServerChatEventHandler(client_ServerBroadcast);
            client.ServerErrorReceived += new ServerChatEventHandler(client_ServerErrorReceived);
            client.UserShown += new UserEventHandler(client_UserShown);
            client.UserJoined += new UserEventHandler(client_UserJoined);
            client.UserLeft += new UserEventHandler(client_UserLeft);
            client.UserSpoke += new ChatMessageEventHandler(client_UserSpoke);
            client.UserEmoted += new ChatMessageEventHandler(client_UserEmoted);
            client.ClientCheckPassed += delegate { Console.WriteLine("--- VERSIONING PASSED"); };
            client.ClientCheckFailed += new ClientCheckFailedEventHandler(client_ClientCheckFailed);
            client.JoinedChannel += new ServerChatEventHandler(client_JoinedChannel);
            client.WardentUnhandled += delegate { Console.WriteLine("--- WARNING: Warden requested and unhandled!!"); };
            client.MessageSent += new ChatMessageEventHandler(client_MessageSent);
            client.Disconnected += delegate { Console.WriteLine("--- DISCONNECTED"); };

            BattleNetClientResources.IncomingBufferPool.NewBufferAllocated += new EventHandler(BufferAllocated);
            BattleNetClientResources.OutgoingBufferPool.NewBufferAllocated += new EventHandler(BufferAllocated);

            Console.WriteLine("Events hooked up; press <enter> to connect.");
            Console.ReadLine();

            Console.WriteLine("Type /exit to quit.");

            client.Connect();

            string text;
            bool exit = false;
            do
            {
                text = Console.ReadLine();
                if (!text.Equals("/exit", StringComparison.Ordinal))
                {
                    client.SendMessage(text);
                }
                else
                {
                    exit = true;
                }
            } while (!exit);

            client.Close();
            Console.WriteLine("Disconnected; press <enter> to exit.");
            Console.ReadLine();

        }
コード例 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Logging on with Starcraft; enter CD key.");
            string cdKey = Console.ReadLine().Trim();

            Console.WriteLine("Enter account name:");
            string acct = Console.ReadLine().Trim();

            Console.WriteLine("Enter account password for {0}:", acct);
            string password = Console.ReadLine().Trim();

            Settings set = new Settings()
            {
                CdKey1 = cdKey, Username = acct, Password = password, CdKeyOwner = acct
            };

            BattleNetClient client = new BattleNetClient(set);

            client.Connected           += delegate { Console.WriteLine("--- CONNECTED"); };
            client.Error               += new ErrorEventHandler(client_Error);
            client.EnteredChat         += new EnteredChatEventHandler(client_EnteredChat);
            client.LoginSucceeded      += new EventHandler(client_LoginSucceeded);
            client.LoginFailed         += new LoginFailedEventHandler(client_LoginFailed);
            client.ServerBroadcast     += new ServerChatEventHandler(client_ServerBroadcast);
            client.ServerErrorReceived += new ServerChatEventHandler(client_ServerErrorReceived);
            client.UserShown           += new UserEventHandler(client_UserShown);
            client.UserJoined          += new UserEventHandler(client_UserJoined);
            client.UserLeft            += new UserEventHandler(client_UserLeft);
            client.UserSpoke           += new ChatMessageEventHandler(client_UserSpoke);
            client.UserEmoted          += new ChatMessageEventHandler(client_UserEmoted);
            client.ClientCheckPassed   += delegate { Console.WriteLine("--- VERSIONING PASSED"); };
            client.ClientCheckFailed   += new ClientCheckFailedEventHandler(client_ClientCheckFailed);
            client.JoinedChannel       += new ServerChatEventHandler(client_JoinedChannel);
            client.WardentUnhandled    += delegate { Console.WriteLine("--- WARNING: Warden requested and unhandled!!"); };
            client.MessageSent         += new ChatMessageEventHandler(client_MessageSent);
            client.Disconnected        += delegate { Console.WriteLine("--- DISCONNECTED"); };

            BattleNetClientResources.IncomingBufferPool.NewBufferAllocated += new EventHandler(BufferAllocated);
            BattleNetClientResources.OutgoingBufferPool.NewBufferAllocated += new EventHandler(BufferAllocated);

            Console.WriteLine("Events hooked up; press <enter> to connect.");
            Console.ReadLine();

            Console.WriteLine("Type /exit to quit.");

            client.Connect();

            string text;
            bool   exit = false;

            do
            {
                text = Console.ReadLine();
                if (!text.Equals("/exit", StringComparison.Ordinal))
                {
                    client.SendMessage(text);
                }
                else
                {
                    exit = true;
                }
            } while (!exit);

            client.Close();
            Console.WriteLine("Disconnected; press <enter> to exit.");
            Console.ReadLine();
        }