using System;
using MSNP;
namespace MSNP.CommandParsers{
/// <summary>
/// Summary description for IDCommandParser.
/// </summary>
internal class IDCommandParser : ICommandParser
{
protected internal IDCommandParser() {}
public Response ParseResponse(string rawResponse)
{
string curCommand;
int curTransactionID = -1;
string[] curParameters = new string[0];
string[] allParts = rawResponse.Trim().Split(new char[] {' '}, 3);
int curPart = 0;
if( allParts.Length > 0 )
{
curCommand = allParts[curPart++];
if( allParts.Length > 1 )
curTransactionID = System.Int32.Parse(allParts[curPart++]);
if( allParts.Length > 2 )
curParameters = allParts[curPart++].Split(new char[] {' '});
return new Response(curCommand, curTransactionID, curParameters);
}
else
throw new Exception("Invalid response from server: " + rawResponse);
}
}
}
|