예제 #1
0
        public ServerReplyMessage GetServerReply(IRCReplyCode replyCode, string match)
        {
            GetReply reply = new GetReply();

            reply.Reply       = replyCode;
            reply.Match       = match;
            ServerReplyEvent += (sender, e) => HandleReply(sender, e, reply);
            reply.Ready.Wait(TimeSpan.FromMilliseconds(5000));
            return(reply.Result);
        }
예제 #2
0
        private void HandleReply(object sender, IReply message, GetReply reply)
        {
            bool  replyFound = false;
            Regex replyRegex = new Regex(reply.Match);

            if (message.GetType() == typeof(ServerReplyMessage))
            {
                ServerReplyMessage msg = (ServerReplyMessage)message;
                replyFound = reply.Reply.Equals(msg.ReplyCode);

                if (replyFound && replyRegex.IsMatch(msg.Message))
                {
                    reply.Result = msg;
                    reply.Ready.Set();
                }
            }
        }