public void WriteMessage(AMFMessage amfMessage) { try { base.WriteShort(amfMessage.Version); int headerCount = amfMessage.HeaderCount; base.WriteShort(headerCount); for (int i = 0; i < headerCount; i++) { this.WriteHeader(amfMessage.GetHeaderAt(i), ObjectEncoding.AMF0); } int bodyCount = amfMessage.BodyCount; base.WriteShort(bodyCount); for (int i = 0; i < bodyCount; i++) { ResponseBody responseBody = amfMessage.GetBodyAt(i) as ResponseBody; if (responseBody != null && !responseBody.IgnoreResults) { if (this.BaseStream.CanSeek) { long position = this.BaseStream.Position; try { responseBody.WriteBody(amfMessage.ObjectEncoding, this); } catch (Exception exception) { throw exception; } } else { responseBody.WriteBody(amfMessage.ObjectEncoding, this); } } else { AMFBody amfBody = amfMessage.GetBodyAt(i); amfBody.WriteBody(amfMessage.ObjectEncoding, this); } } } catch (Exception exception) { throw exception; } }
private AMFBody ReadBody() { Reset(); string target = base.ReadString(); // Response that the client understands. string response = base.ReadString(); int length = base.ReadInt32(); try { object content = base.ReadData(); AMFBody amfBody = new AMFBody(target, response, content); return(amfBody); } catch (Exception exception) { throw exception; } }
public void AddBody(AMFBody body) { _bodies.Add(body); }