static bool isErrorMessage(ParseMessage parseMessage) { return parseMessage == ParseMessage.BlockError || parseMessage == ParseMessage.InternalError || parseMessage == ParseMessage.LexicalError || parseMessage == ParseMessage.SyntaxError; }
void CreateMessagesSchemaOnly(CommandBehavior behavior) { Contract.Requires((behavior & CommandBehavior.SchemaOnly) != 0); ProcessRawQuery(); for (var i = 0; i < _queries.Count; i++) { ParseMessage parseMessage; DescribeMessage describeMessage; if (i == 0) { parseMessage = _connector.ParseMessage; describeMessage = _connector.DescribeMessage; } else { parseMessage = new ParseMessage(); describeMessage = new DescribeMessage(); } _connector.AddMessage(parseMessage.Populate(_queries[i], _connector.TypeHandlerRegistry)); _connector.AddMessage(describeMessage.Populate(StatementOrPortal.Statement)); } _connector.AddMessage(SyncMessage.Instance); }
private async Task <bool> RegisterEventAsync(string id, string eventName) { var response = new ParseMessage( await this.SendCommandAsync($"clientnotifyregister schandlerid={id} event={eventName}")); return(response.IsValid && !response.IsError); }
public ProcessResult TryProcess(TextReader input, XmlWriter output, XmlResolver resolver) { if (input == null) { throw new ArgumentNullException("input"); } if (output == null) { throw new ArgumentNullException("output"); } LalrProcessor parser = new LalrProcessor(new Tokenizer(input, grammar)); ParseMessage message = parser.Parse(); while (CompiledGrammar.CanContinueParsing(message)) { message = parser.Parse(); } LineInfo position = default(LineInfo); if (parser.CurrentToken != null) { position = parser.CurrentToken.Position; } switch (message) { case ParseMessage.Accept: break; case ParseMessage.LexicalError: return(new ProcessResult(position, string.Format("Lexical error: {0}", parser.CurrentToken))); case ParseMessage.SyntaxError: StringBuilder result = new StringBuilder("Syntax error:"); foreach (Symbol expectedSymbol in parser.GetExpectedTokens()) { result.Append(' '); result.Append(expectedSymbol.Name); } result.Append(" expected"); return(new ProcessResult(position, result.ToString())); case ParseMessage.CommentError: return(new ProcessResult(position, "End of block comment not found")); default: // includes InternalError return(new ProcessResult(position, "Internal error")); } StringBuilder xsltError = new StringBuilder(); XsltArgumentList arguments = new XsltArgumentList(); arguments.XsltMessageEncountered += ((sender, args) => xsltError.Append(args.Message)); using (XmlReader reader = new TokenXmlReader(nametable, parser.CurrentToken)) { transform.Transform(reader, arguments, output, resolver); } if (xsltError.Length > 0) { return(new ProcessResult(default(LineInfo), xsltError.ToString())); } return(new ProcessResult()); }
public void testMorozovEngine(string cgtFile, string sourceFile) { FileStream fs = new FileStream(cgtFile, FileMode.Open, FileAccess.Read); BinaryReader reader = new BinaryReader(fs); Grammar grammar = new Grammar(reader); FileStream sourceStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(sourceStream); String source = sr.ReadToEnd(); TimeSpan timeStart = new TimeSpan(DateTime.Now.Ticks); Parser parser = new Parser(source, grammar); ParseMessage response = ParseMessage.Empty; while (response != ParseMessage.Accept) { response = parser.Parse(); } /* * for (int i = 0; i < 1000; i++) * { * Parser parser = new Parser(source, grammar); * ParseMessage response = ParseMessage.Empty; * while (response != ParseMessage.Accept) * { * response = parser.Parse(); * } * } */ TimeSpan timeEnd = new TimeSpan(DateTime.Now.Ticks); this.outputBox.AppendText("Took " + timeEnd.Subtract(timeStart).ToString() + "\n"); }
public async Task Start(ParseMessage parseMessage) { _source = new CancellationTokenSource(); PeriodicTaskAction <object, CancellationToken> keepChannel = (async(object o, CancellationToken t) => { if (_webSocketClient == null) { _webSocketClient = new ClientWebSocket(); _webSocketClient.Options.KeepAliveInterval = new TimeSpan(keepAliveSocketInterval * TimeSpan.TicksPerSecond); await SocketConnect(parseMessage); } else if (_webSocketClient.State != WebSocketState.Open && _webSocketClient.State != WebSocketState.Connecting) { _webSocketClient.Dispose(); _webSocketClient = new ClientWebSocket(); _webSocketClient.Options.KeepAliveInterval = new TimeSpan(keepAliveSocketInterval * TimeSpan.TicksPerSecond); await SocketConnect(parseMessage); } } ); tickerchnl = new PeriodicTaskWrapper(_logger, _name); await tickerchnl.Start(keepChannel, new PeriodicTaskParams { period = (int)keepAliveSecs * 1000 }, _source.Token); }
public void AddOutputMessage(int Line, string Text) { ParseMessage message = new ParseMessage(ParseMessage.LineType.MESSAGE, Types.ErrorCode.OK, Text); Messages.Add(Line, message); ++m_Messages; }
public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) { Match output = Regex.Match(message.Body, @"^!(?:calc|eval) (.+)", RegexOptions.IgnoreCase | RegexOptions.Singleline); if (output.Success) { String exp = output.Groups[1].Value; SemanticProcessor <MathToken> processor = new SemanticProcessor <MathToken>(new StringReader(exp), actions); ParseMessage parseMessage = processor.ParseAll(); if (parseMessage == ParseMessage.Accept) { message.Chat.SendMessage( String.Format( "{0} = {1}", exp, ((Computable)processor.CurrentToken).GetValue())); } else { IToken token = processor.CurrentToken; message.Chat.SendMessage(string.Format("{0} ({1} on line {2}, column {3})", parseMessage, token.Symbol, token.Position.Line, token.Position.Column)); } } }
public object Exec(string input, ExecutionContext ctx) { var processor = new SemanticProcessor <GCToken>(new StringReader(input), actions); ParseMessage parseMessage = processor.ParseAll(); if (parseMessage == ParseMessage.Accept) { var statement = processor.CurrentToken as Expression; if (statement != null) { try { return(statement.GetValue(ctx)); } catch (FormulaSolverException ex) { return("??" + ex.Message); } } } else { IToken token = processor.CurrentToken; return(String.Format("??Syntax error at: {0} [{1}]", token.Position.Index, parseMessage)); } return(null); }
private static void Main(string[] args) { Console.WriteLine("Language Scrappy Compiler 1.0"); if (args.Length == 0) { Console.WriteLine("usage: Scrappy <file.sp>"); return; } var grammar = CompiledGrammar.Load(typeof(Program), "Scrappy.egt"); var actions = new SemanticTypeActions <BaseToken>(grammar); try { actions.Initialize(true); } catch (InvalidOperationException ex) { Console.Write("Error: " + ex.Message); return; } try { var path = args[0]; var outputName = Path.GetFileNameWithoutExtension(path) + ".xml"; using (var reader = File.OpenText(path)) { var processor = new SemanticProcessor <BaseToken>(reader, actions); ParseMessage parseMessage = processor.ParseAll(); if (parseMessage == ParseMessage.Accept) { Console.WriteLine("Parsing done."); var compilationModel = new CompilationModel(File.ReadAllLines(path)); var start = (Start)processor.CurrentToken; start.Compile(compilationModel); // first classes, fields and methods needs to be compiled compilationModel.Compile(); // after that compile method body Console.WriteLine("Compiling done."); using (var outfile = new StreamWriter(outputName)) { outfile.Write(compilationModel.ToXml()); } // PrintAst(start); // only for debugging } else { IToken token = processor.CurrentToken; Console.WriteLine(token.Symbol); Console.WriteLine("Error: Line: {0} Column: {1} Error: {2}", token.Position.Line, token.Position.Column, parseMessage); } } } catch (Exception e) { Console.WriteLine("Error" + e.Message); } }
public ParseMessage AddSevereWarning(int Line, Types.ErrorCode Code, string Text) { ParseMessage warningMessage = new ParseMessage(ParseMessage.LineType.SEVERE_WARNING, Code, Text); Messages.Add(Line, warningMessage); ++m_WarningMessages; return(warningMessage); }
public ParseMessage AddWarning(int Line, Types.ErrorCode Code, string Text, int CharIndex, int Length) { ParseMessage warningMessage = new ParseMessage(ParseMessage.LineType.WARNING, Code, Text, CharIndex, Length); Messages.Add(Line, warningMessage); ++m_WarningMessages; return(warningMessage); }
public ParseMessage AddError(int Line, Types.ErrorCode Code, string Text) { ParseMessage errorMessage = new ParseMessage(ParseMessage.LineType.ERROR, Code, Text, -1, 0); Messages.Add(Line, errorMessage); ++m_ErrorMessages; return(errorMessage); }
private void AddParseAction(Parser parser, ParseMessage action, string description, string reductionNo, string value, string tableIndex) { if (m_parseAction != null) { m_parseAction(parser, action, description, reductionNo, value, tableIndex); } }
public ParseMessage AddError(int Line, Types.ErrorCode Code, string Text, int CharIndex, int Length) { ParseMessage errorMessage = new ParseMessage(ParseMessage.LineType.ERROR, Code, Text, CharIndex, Length); Messages.Add(Line, errorMessage); ++m_ErrorMessages; return(errorMessage); }
public static T SerializeObjectFromStrings <T> ( IEnumerable <string> sourceItems, string firstOptionalField, ref ParseMessage error ) where T : class { return(SerializeObjectFromStrings(typeof(T), sourceItems, firstOptionalField, ref error) as T); }
public ParseMessage Parse(string query) { NCQLParser parser = new NCQLParser(ResourceName, _ncacheLog); System.IO.TextReader tr = new System.IO.StringReader(query); ParseMessage message = parser.Parse(tr, true); _currentReduction = parser.CurrentReduction; return(message); }
public async Task <CQConnectionStatus> CaptureChatMessages() { // Consume Headers. if (!await this.ConsumeHeadersAsync()) { return(CQConnectionStatus.CannotRecover); } // Authentication Process. Log($"Attempting to Authorize with \"auth apikey={this.m_ts3ApiKey}\"..."); this.m_client.WriteLine($"auth apikey={this.m_ts3ApiKey}"); var response = new ParseMessage(await this.m_client.ReadAsync()); if (!response.IsValid || response.IsError) { return(response.IsValid ? CQConnectionStatus.AuthKeyError : CQConnectionStatus.WaitingForServer); } // Start hooking up events for TTS feature. Log("Connection established"); SendStatueMessage("Connection Established!"); if (!await this.RegisterForTextMessagesAsync()) { return(CQConnectionStatus.CannotRecover); } this.TeamSpeakCQKeepAlive(initialize: true); // Start the timing mechanism. while (true) { string textMsg = await this.m_client.ReadAsync(); // Automatically returns after client's built in timeout. if (textMsg == null) { return(CQConnectionStatus.Disconnected); } if (textMsg == "") { this.TeamSpeakCQKeepAlive(); // Let's do the keep-alive event here. if (ConnectionStatus == CQConnectionStatus.Paused) { this.m_client.WriteLine("quit"); } continue; } if (textMsg.EndsWith("\n")) { textMsg = textMsg.Substring(0, textMsg.Length - 1); } LogClientResponse(textMsg); this.PrepareTtsSendOff(textMsg); } }
/// <summary> /// Reads next token from the input stream. /// </summary> /// <returns>Token symbol which was read.</returns> public virtual ParseMessage NextToken(out T token) { Symbol tokenSymbol; int offset = 0; ParseMessage result = NextSymbol(DummyGroup.Default, MergeLexicalErrors ? ParseMode.MergeLexicalErrors : ParseMode.SingleSymbol, out tokenSymbol, ref offset); LineInfo position; string text = buffer.Read(offset, out position); token = CreateToken(tokenSymbol, position, text); return(result); }
public void AddMessage(string Message, string AlternativeFile, int AlternativeLineIndex, int CharIndex, int Length) { if (ChildMessages == null) { ChildMessages = new List <ParseMessage>(); } var childMessage = new ParseMessage(Type, Code, Message, AlternativeFile, AlternativeLineIndex); childMessage.ParentMessage = this; ChildMessages.Add(childMessage); }
/// <summary> /// Executa o parser na consulta. /// </summary> /// <param name="query"></param> /// <returns></returns> public ParseMessage Parse(string query) { using (var parser = new CQLParser("Colosoft.Caching.Resources.cql.cgt", _logger)) { using (var source = new System.IO.StringReader(query)) { ParseMessage message = parser.Parse(source, true); _currentReduction = parser.CurrentReduction; return(message); } } }
public static bool CanContinueParsing(ParseMessage message) { switch (message) { case ParseMessage.BlockRead: case ParseMessage.CommentLineRead: case ParseMessage.Reduction: case ParseMessage.TokenRead: return(true); } return(false); }
public ParseMessage AddSevereWarning(int Line, Types.ErrorCode Code, string Text) { if (m_CompileConfig.WarningsToTreatAsError.ContainsValue(Code)) { return(AddError(Line, Code, Text)); } ParseMessage warningMessage = new ParseMessage(ParseMessage.LineType.SEVERE_WARNING, Code, Text); Messages.Add(Line, warningMessage); ++m_WarningMessages; return(warningMessage); }
public ParseMessage AddWarning(int Line, Types.ErrorCode Code, string Text, int CharIndex, int Length) { if (m_CompileConfig.WarningsToTreatAsError.ContainsValue(Code)) { return(AddError(Line, Code, Text, CharIndex, Length)); } ParseMessage warningMessage = new ParseMessage(ParseMessage.LineType.WARNING, Code, Text, CharIndex, Length); Messages.Add(Line, warningMessage); ++m_WarningMessages; return(warningMessage); }
void Parse(JsonTestSuite suite) { using (var reader = new StringReader(suite.Json)) { var tokenizer = new Tokenizer(reader, grammar); var processor = new LalrProcessor(tokenizer, true); ParseMessage parseMessage = processor.ParseAll(); if (parseMessage != ParseMessage.Accept) { // you could build a detailed error message here: // the position is in processor.CurrentToken.Position // and use processor.GetExpectedTokens() on syntax errors throw new InvalidOperationException("Parsing failed"); } } }
void Parse(XmlTestSuite suite) { using (var reader = new StringReader(suite.Xml)) { var tokenizer = new Tokenizer(reader, grammar); var processor = new LalrProcessor(tokenizer, true); ParseMessage parseMessage = processor.ParseAll(); if (parseMessage != ParseMessage.Accept) { // you could build a detailed error message here: // the position is in processor.CurrentToken.Position // and use processor.GetExpectedTokens() on syntax errors var ct = processor.CurrentToken; throw new InvalidOperationException(string.Format("Parsing failed, position: {0}, text: {1}", ct.Position, ct.Text)); } } }
public override object Execute(JsonSuite suite) { using (var reader = new StringReader(suite.Json)) { var tokenizer = new Tokenizer(reader, grammar); var processor = new LalrProcessor(tokenizer, true); ParseMessage parseMessage = processor.ParseAll(); if (parseMessage != ParseMessage.Accept) { // you could build a detailed error message here: // the position is in processor.CurrentToken.Position // and use processor.GetExpectedTokens() on syntax errors throw new InvalidOperationException("Parsing failed"); } return(null); // how do we actually get the results?? wierd. } }
public static System.Object SerializeObjectFromStrings ( System.Type type, IEnumerable <string> sourceItems, string firstOptionalField, ref ParseMessage error ) { try { var sourceQueue = new Queue <string>(sourceItems); return(sourceQueue.DequeueObject(type, firstOptionalField)); } catch (System.Exception exception) { error = new ParseMessage("Error building " + type.ToString(), sourceItems, exception.ToString()); } return(null); }
public bool Process(ParseMessage pm, ref int actionCounter) { // read stratum lines from network List <string> receivedLines = ReadNetworkData(); // parse stratum lines into stratum messages foreach (string line in receivedLines) { actionCounter++; Logging.Log(5, "Received from miner: " + line); StratumMessageClient smc = StratumMessage.ParseClientMessage(line); if (smc != null) { receivedMessages.Enqueue(smc); } else { Logging.Log(5, "Invalid stratum message: " + line); // todo: handle non supported messages? } } // process stratum messages while (receivedMessages.Count > 0) { actionCounter++; StratumMessageClient smc = receivedMessages.Dequeue(); if (!pm(this, smc)) { return(false); } } // check if connection is dead if (connection.Client.Poll(0, SelectMode.SelectRead) && connection.Client.Available == 0) { return(false); } return(true); }
bool?parse() { ParseMessage response = m_parser.Parse(); switch (response) { case ParseMessage.LexicalError: return(OnLexicalError()); case ParseMessage.SyntaxError: return(OnSyntaxError()); case ParseMessage.Reduction: return(OnReduction()); case ParseMessage.Accept: return(OnAccept()); case ParseMessage.TokenRead: return(OnTokenRead()); case ParseMessage.InternalError: //INTERNAL ERROR! Something is horribly wrong. return(OnError(response, "Internal error")); case ParseMessage.NotLoadedError: //This error occurs if the CGT was not loaded. return(OnError(response, "Tables not loaded")); case ParseMessage.GroupError: //GROUP ERROR! Unexpected end of file return(OnError(response, "Runaway group")); default: return(OnError(response, "Unexpected response")); } }
public static ParseResult Parse(string txt) { if (txt == null) throw new ArgumentNullException(nameof(txt)); // based on skeleton code generated by Gold Parser Builder 5.2 (http://www.goldparser.org) FailMessage = null; ParseResult result = new ParseResult(); Parser.Open(ref txt); while (true) { ParseMessage response = Parser.Parse(); switch (response) { case ParseMessage.Reduction: if (Parser.CurrentReduction is Reduction reduction) { switch ((ProductionIndex)reduction.Parent.TableIndex()) { case ProductionIndex.Name_Identifier: // <Name> ::= Identifier result.Name = reduction.get_Data(0) as string; break; case ProductionIndex.Isidentity_Identity: // <Is Identity> ::= Identity result.IsIdentity = reduction.get_Data(0) as string == "!"; break; case ProductionIndex.Isoptional_Optional: // <Is Optional> ::= Optional result.Required = reduction.get_Data(0) as string != "?"; break; case ProductionIndex.Maxlength_Lbracket_Decliteral_Rbracket: case ProductionIndex.Maxlength_Lparen_Decliteral_Rparen: case ProductionIndex.Maxlength_Lbracketmaxrbracket: case ProductionIndex.Maxlength_Lparenmaxrparen: // <Max Length> ::= '[' DecLiteral ']' // <Max Length> ::= '(' DecLiteral ')' // <Max Length> ::= '[max]' // <Max Length> ::= '(max)' if (reduction.get_Data(0) is string maxLength && (maxLength.ToLowerInvariant() == "[max]" || maxLength.ToLowerInvariant() == "(max)")) { result.MaxLength = ModelAttribute.MAXLENGTH_MAX; break; } result.MaxLength = int.TryParse(reduction.get_Data(1) as string, out int _max0) ? (int?)_max0 : null; break; case ProductionIndex.Lengths_Lbracket_Decliteral_Minus_Decliteral_Rbracket: case ProductionIndex.Lengths_Lparen_Decliteral_Minus_Decliteral_Rparen: case ProductionIndex.Lengths_Lbracket_Decliteral_Minus_Max_Rbracket: case ProductionIndex.Lengths_Lparen_Decliteral_Minus_Max_Rparen: case ProductionIndex.Lengths_Lbracket_Decliteral_Minus_Rbracket: case ProductionIndex.Lengths_Lparen_Decliteral_Minus_Rparen: // <Lengths> ::= '[' DecLiteral '-' DecLiteral ']' // <Lengths> ::= '(' DecLiteral '-' DecLiteral ')' // <Lengths> ::= '[' DecLiteral '-' max ']' // <Lengths> ::= '(' DecLiteral '-' max ')' // <Lengths> ::= '[' DecLiteral '-' ']' // <Lengths> ::= '(' DecLiteral '-' ')' if (reduction.get_Data(1) is string minLengthData && reduction.get_Data(3) is string maxLengthData) { result.MinLength = int.TryParse(minLengthData, out int _min) ? (int?)_min : null; if (maxLengthData == ModelAttribute.MAXLENGTH_MAX.ToString()) result.MaxLength = ModelAttribute.MAXLENGTH_MAX; else if (maxLengthData == ModelAttribute.MAXLENGTH_UNDEFINED.ToString()) result.MaxLength = null; else { switch (maxLengthData) { case "]": case ")": result.MaxLength = ModelAttribute.MAXLENGTH_UNDEFINED; break; case "max": result.MaxLength = ModelAttribute.MAXLENGTH_MAX; break; default: result.MaxLength = int.TryParse(reduction.get_Data(3) as string, out int _max1) ? (int?)_max1 : null; break; } } } if (result.MinLength < 0) { FailMessage = "Min length can't be a negative number"; return null; } if (result.MaxLength.HasValue && result.MaxLength > 0 && result.MinLength > result.MaxLength) { FailMessage = "Min length cannot be greater than max length"; return null; } break; case ProductionIndex.Type_Identifier: // <Type> ::= Identifier result.Type = reduction.get_Data(0) as string; break; case ProductionIndex.Type_Timestamptype: // <Type> ::= TimestampType result.Type = "Binary"; break; case ProductionIndex.Enumvalue_Identifier_Dot_Identifier: // <EnumValue> ::= Identifier '.' Identifier result.InitialValue = $"{reduction.get_Data(0) as string}.{reduction.get_Data(2) as string}"; break; case ProductionIndex.Visibility_Public: // <Visibility> ::= public result.SetterVisibility = SetterAccessModifier.Public; break; case ProductionIndex.Visibility_Protected: // <Visibility> ::= protected result.SetterVisibility = SetterAccessModifier.Protected; break; case ProductionIndex.Visibility_Internal: // <Visibility> ::= internal result.SetterVisibility = SetterAccessModifier.Internal; break; case ProductionIndex.Initialvalue_Decliteral: case ProductionIndex.Initialvalue_Hexliteral: case ProductionIndex.Initialvalue_Realliteral: // <Initial Value> ::= DecLiteral | HexLiteral | RealLiteral result.InitialValue = reduction.get_Data(0) as string; break; case ProductionIndex.Initialvalue_Stringliteral: // <Initial Value> ::= StringLiteral result.InitialValue = $"\"{(reduction.get_Data(0) as string).Trim('"')}\""; break; case ProductionIndex.Initialvalue_Charliteral: // <Initial Value> ::= CharLiteral result.InitialValue = $"'{(reduction.get_Data(0) as string).Trim('"', '\'')}'"; break; } } break; case ParseMessage.Accept: return result; case ParseMessage.TokenRead: break; case ParseMessage.LexicalError: //Cannot recognize token FailMessage = $"Lexical Error:\nPosition: {Parser.CurrentPosition().Column}\nRead: {Parser.CurrentToken().Data}"; return null; case ParseMessage.SyntaxError: //Expecting a different token FailMessage = $"Syntax Error:\nPosition: {Parser.CurrentPosition().Column}\nRead: {Parser.CurrentToken().Data}\nExpecting: {Parser.ExpectedSymbols().Text()}"; return null; case ParseMessage.InternalError: return null; case ParseMessage.NotLoadedError: //This error occurs if the CGT was not loaded. FailMessage = "Tables not loaded"; return null; case ParseMessage.GroupError: //GROUP ERROR! Unexpected end of file FailMessage = "Runaway group"; return null; } } }
public static bool CanContinueParsing(ParseMessage message) { switch (message) { case ParseMessage.BlockRead: case ParseMessage.CommentLineRead: case ParseMessage.Reduction: case ParseMessage.TokenRead: return true; } return false; }
public ParseException(string message, ParseMessage parseMessage, LineInfo position, Exception innerException): base(message, innerException) { this.position = position; this.parseMessage = parseMessage; }
private void GatherUserInformation( ParseMessage.Message msg ) { switch ( msg.Command.ToUpper() ) { case "USER": userName = msg.Params.Last<string>(); break; case "NICK": nickName = msg.Params.Last<string>(); break; default: break; } if ( !string.IsNullOrEmpty( userName ) && !string.IsNullOrEmpty( nickName ) ) { _state = States.Active; SendStartupInformation(); } }
private void HandleUserMessages( ParseMessage.Message msg ) { throw new NotImplementedException(); }
void InitialState( ParseMessage.Message msg ) { switch ( msg.Command.ToUpper() ) { case "PASS": password = msg.Params.Last<string>(); _state = States.Information; break; default: break; } }
void _parser_MessageRecievedEvent( object sender, ParseMessage.Message msg ) { switch ( _state ) { case States.Initial: InitialState( msg ); break; case States.Information: GatherUserInformation( msg ); break; case States.Active : HandleUserMessages( msg ); break; } Program.MainForm.DebugMessage( String.Format( "ClientMessage {0}", msg.ToString() ) ); }
protected virtual bool? OnError(ParseMessage response, string message) { m_FailMessage = message; return false; }
void irc_MessageRecievedEvent(object sender, ParseMessage.Message msg) { string reply = String.Empty; Debug( msg.ToString() ); switch ( msg.Command.ToUpper() ) { case "PRIVMSG": Message( String.Format( "[{0}]", msg.NickName ?? msg.ServerName ), msg.Params.Last<string>() ); break; case "PING": reply = String.Format( "PONG {0}{1}{2}", msg.Params[ 0 ], msg.Params.Count > 1 && msg.Params[ 1 ].Length > 0 ? " " : "", msg.Params.Count > 1 && msg.Params[ 1 ].Length > 0 ? msg.Params[ 1 ] : "" ); break; case "NOTICE" : Message( "** " + msg.Params.Last<string>() ); break; case "001": case "002": case "003": case "004": case "251" : case "252" : case "253": case "254": case "255": case "266": case "375": case "372": case "MODE": case "332": case "333": case "250" : case "265" : Message( msg.Params.Last<string>() ); break; case "353": string[] names = msg.Params.Last<string>().Split( ' ' ) ; foreach ( string s in names ) { this.Invoke( new MethodInvoker( delegate { AddUserName( s ); } ) ); } break ; case "JOIN": Message( String.Format( "** {0} has joined {1}", msg.NickName, msg.Params.Last<string>() ) ); this.Invoke( new MethodInvoker( delegate { AddUserName( msg.NickName ); } ) ); break; case"005": case "366": case "376": break; //Unhandled Command ->QUIT // Server -> // NickeName -> MrKotter // Host -> ool-4356245d.dyn.optonline.net // User -> ~MrKotter // -->Quit: MrKotter case "QUIT": Message( String.Format( "** {0} has quit", msg.NickName ) ); this.Invoke( new MethodInvoker( delegate { RemoveUserName( msg.NickName ); } ) ); break; //Unhandled Command ->NICK // Server -> //NickeName -> ptorre_ // Host -> xd8ad0a72.ip.e-nt.net // User -> ~ptorre // --> shoebootie case "NICK": Message( String.Format( "{0} is now {1}", msg.NickName, msg.Params.Last<string>() ) ) ; if ( this.InvokeRequired ) { this.Invoke( new MethodInvoker( delegate { ChangeUserName( msg.NickName, msg.Params.Last<string>() ); } ) ); } else { ChangeUserName( msg.NickName, msg.Params.Last<string>() ) ; } break ; default: Debug( "Unhandled Command ->" + msg.Command ); Debug( " Server -> " + msg.ServerName ) ; Debug( " NickeName -> " + msg.NickName ) ; Debug( " Host -> " + msg.Host ) ; Debug( " User -> " + msg.User ); foreach ( var s in msg.Params ) Debug( " --> " + s ); break; } if ( reply.Length > 0 ) { SendMsgToServer( reply ); } }