public byte[] StartStream(string domain, string resource)
{
var attributes = new List<KeyValue>();
this.buffer = new List<byte>();
attributes.Add(new KeyValue("to", domain));
attributes.Add(new KeyValue("resource", resource));
this.writeListStart(attributes.Count * 2 + 1);
this.buffer.Add(1);
this.writeAttributes(attributes.ToArray());
byte[] ret = this.flushBuffer();
this.buffer.Add((byte)'W');
this.buffer.Add((byte)'A');
this.buffer.Add(0x1);
this.buffer.Add(0x2);
this.buffer.AddRange(ret);
ret = buffer.ToArray();
this.buffer = new List<byte>();
return ret;
}