void ProcessServerSmsResponse(ByteStream data) { data.AdvanceOffset(1); // skip success byte data.AdvanceOffset(8); // skip unknown fields // length of xml response ushort xmlen = data.ReadUshort(); // read response string xml = data.ReadString(xmlen, Encoding.ASCII); // parse xml System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(xml); System.Xml.XmlNode node = doc.SelectSingleNode("/sms_response/deliverable"); bool deliverable = false; // check if sms delivered if (node != null && node.InnerText.ToLower() == "yes") { deliverable = true; } // sms info string messageId = null; string error = null; string param = null; if (deliverable) { node = doc.SelectSingleNode("/sms_response/message_id"); if (node != null) { messageId = node.InnerText; } } else { node = doc.SelectSingleNode("/sms_response/error/id"); error = node.InnerText; node.SelectSingleNode("/params/param"); param = node.InnerText; } doc = null; if (deliverable) { SmsMessageSent(this, messageId); } else { SmsMessageError(this, error, param); } }
private void ProcessMetaDataReply(string uin, DataPacket dp, ByteStream data) { MetaResponseSubType responseSubType = (MetaResponseSubType)data.ReadUshortLE(); switch (responseSubType) { case MetaResponseSubType.MetaProcessError: data.AdvanceOffset(1); // skip status byte // get error message string errorDesc = data.ReadNullTerminatedString(data.GetByteCount() - data.CurrentPosition); SmsMessageError(this, "46", errorDesc); break; case MetaResponseSubType.ServerSmsResponse: this.ProcessServerSmsResponse(data); break; case MetaResponseSubType.SetPasswordAck: this.ProcessSetPasswordAck(dp, data); break; case MetaResponseSubType.ShortUserInfoResponse: this.ProcessShortUserInfoResponse(dp, data); break; case MetaResponseSubType.DirectoryQueryData: case MetaResponseSubType.DirectoryQueryResponse: this.ProcessDirectoryQueryResponse(dp, data); break; case MetaResponseSubType.DirectoryUpdateAck: this.ProcessDirectoryUpdateAck(dp, data); break; default: this.ProcessSearchResult(uin, responseSubType, data); break; } }