private void _SimpleParser(object sender, ReadLineEventArgs args)
{
string rawline = args.Line;
string[] rawlineex = rawline.Split(new char[] {' '});
string messagecode = "";
if (rawline[0] == ':') {
messagecode = rawlineex[1];
ReplyCode replycode = ReplyCode.Null;
try {
replycode = (ReplyCode)int.Parse(messagecode);
} catch (FormatException) {
}
if (replycode != ReplyCode.Null) {
switch (replycode) {
case ReplyCode.Welcome:
_IsRegistered = true;
#if LOG4NET
Logger.Connection.Info("logged in");
#endif
break;
}
} else {
switch (rawlineex[1]) {
case "PONG":
DateTime now = DateTime.UtcNow;
_LastPongReceived = now;
_Lag = now - _LastPingSent;
#if LOG4NET
Logger.Connection.Debug("PONG received, took: "+_Lag.TotalMilliseconds+" ms");
#endif
break;
}
}
} else {
messagecode = rawlineex[0];
switch (messagecode) {
case "ERROR":
IsConnectionError = true;
break;
}
}
}