Exemplo n.º 1
0
        /// <summary>
        /// Connect to a vBulletin chatbox.
        /// </summary>
        /// <param name="forumConfig">Forum configuration.</param>
        /// <param name="decompiler">A correctly configured HTML decompiler, or null.</param>
        /// <param name="timeout">The timeout for HTTP connections.</param>
        public ChatboxConnector(Config.ForumConfig forumConfig, HtmlDecompiler decompiler = null, int timeout = 10000)
        {
            ForumConfig = forumConfig;
            Decompiler  = decompiler;
            Timeout     = timeout;

            // assume a good default for these
            ServerEncoding   = Encoding.GetEncoding("windows-1252", EncoderFallback.ExceptionFallback, DecoderFallback.ExceptionFallback);
            TimeBetweenReads = 5;
            DSTUpdateMinute  = 3;
            MessageIDPiece   = "misc.php?ccbloc=";
            UserIDPiece      = "member.php?u=";

            // precompute the relevant URLs
            LoginUrl     = new Uri(ForumConfig.Url, "login.php?do=login");
            CheapPageUrl = new Uri(ForumConfig.Url, "faq.php");
            PostEditUrl  = new Uri(ForumConfig.Url, "misc.php");
            MessagesUrl  = new Uri(ForumConfig.Url, "misc.php?show=ccbmessages");
            SmiliesUrl   = new Uri(ForumConfig.Url, "misc.php?do=showsmilies");
            AjaxUrl      = new Uri(ForumConfig.Url, "ajax.php");
            DSTUrl       = new Uri(ForumConfig.Url, "profile.php?do=dst");

            // prepare the reading thread
            _readingThread = new Thread(PerformReading)
            {
                Name = "ChatboxConnector reading"
            };
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new chatbox message.
 /// </summary>
 /// <param name="messageID">The ID of the message.</param>
 /// <param name="userID">The ID of the user who posted this message.</param>
 /// <param name="userNameNode">The name of the user who posted this message.</param>
 /// <param name="bodyNode">The body of the message.</param>
 /// <param name="timestamp">The time at which the message was posted..</param>
 /// <param name="decompiler">The HTML decompiler to use.</param>
 public ChatboxMessage(long messageID, long userID, HtmlNode userNameNode, HtmlNode bodyNode, DateTime?timestamp = null, HtmlDecompiler decompiler = null)
 {
     ID           = messageID;
     UserID       = userID;
     UserNameNode = userNameNode;
     BodyNode     = bodyNode;
     Timestamp    = timestamp ?? DateTime.Now;
     Decompiler   = decompiler ?? new HtmlDecompiler();
 }