public GbxCall(int in_handle, byte[] in_data)
{
this.m_type = MessageTypes.None;
this.m_handle = in_handle;
this.m_xml = Encoding.UTF8.GetString(in_data);
this.m_error_code = 0;
this.m_error_string = "";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(this.m_xml);
XmlElement methodParams = null;
// message is of type request ...
if (xmlDoc["methodCall"] != null)
{
// check message type ...
if (in_handle > 0)
this.m_type = MessageTypes.Callback;
else
this.m_type = MessageTypes.Request;
// try to get the method name ...
if (xmlDoc["methodCall"]["methodName"] != null)
{
this.m_method_name = xmlDoc["methodCall"]["methodName"].InnerText;
}
else
this.m_error = true;
// try to get the mehtod's parameters ...
if (xmlDoc["methodCall"]["params"] != null)
{
this.m_error = false;
methodParams = xmlDoc["methodCall"]["params"];
}
else
this.m_error = true;
}
else if (xmlDoc["methodResponse"] != null) // message is of type response ...
{
// check message type ...
this.m_type = MessageTypes.Response;
if (xmlDoc["methodResponse"]["fault"] != null)
{
Hashtable err_struct = (Hashtable)ParseXml(xmlDoc["methodResponse"]["fault"]);
this.m_error_code = (int)err_struct["faultCode"];
this.m_error_string = (string)err_struct["faultString"];
this.m_error = true;
}
else if (xmlDoc["methodResponse"]["params"] != null)
{
this.m_error = false;
methodParams = xmlDoc["methodResponse"]["params"];
}
else
{
this.m_error = true;
}
}
else
{
this.m_error = true;
}
// parse each parameter of the message, if there are any ...
if (methodParams != null)
{
foreach (XmlElement param in methodParams)
{
this.m_params.Add(ParseXml(param));
}
}
}