CwIRC.Interface.Connect C# (CSharp) 메소드

Connect() 공개 메소드

Connects to the specified IRC server, on the specified port.
public Connect ( string p_server, int p_port ) : bool
p_server string The IRC server to connect to.
p_port int The port of the IRC server to connect to.
리턴 bool
        public bool Connect(string p_server, int p_port)
        {
            try
            {
                connection = new TcpClient(p_server, p_port);
            }
            catch
            {
                return false;
            }
            networkStream = connection.GetStream();
            streamReader = new StreamReader(networkStream);
            streamWriter = new StreamWriter(networkStream);

            worker.RunWorkerAsync();

            return true;
        }

Usage Example

예제 #1
0
        /// <summary>
        /// Constructor for MoronBot.
        /// This is where:
        ///  - All of the Bot's Functions are loaded.
        ///  - Settings is initialized from xml.
        ///  - The initial connection to the server is made.
        /// </summary>
        public MoronBot()
        {
            if (!LoadXML("settings.xml"))
            {
                SaveXML("settings.xml");
            }

            LoadFunctions();

            //PluginLoader.WatchDirectory(Settings.Instance.FunctionPath, FuncDirChanged);

            Nick = Settings.Instance.Nick;

            cwIRC = CwIRC.Interface.Instance;

            cwIRC.MessageReceived += CwIRC_MessageReceived;
            cwIRC.Connect(Settings.Instance.Server, Settings.Instance.Port);
            cwIRC.NICK(Nick);
            cwIRC.USER(Nick, "Nope", "Whatever", "MoronBot 0.1.6");
            cwIRC.SendData("PASS mOrOnBoTuS");
            Say("identify mOrOnBoTuS", "NickServ");

            cwIRC.JOIN(Settings.Instance.Channel);

            connectionTimer.Elapsed += new System.Timers.ElapsedEventHandler(connectionTimer_Elapsed);
            connectionTimer.Interval = 120000;
            connectionTimer.Enabled  = true;
        }
All Usage Examples Of CwIRC.Interface::Connect