public AddStream ( Stream s, bool writeExisingData ) : void | ||
s | Stream | |
writeExisingData | bool | |
return | void |
public void AddStream(Stream s, bool writeExisingData)
{
lock (OutputStreams)
{
if (writeExisingData)
{
foreach (var chunk in internalBuffer)
{
Trace.TraceInformation("AddStream() : Writing chunk for {0}", RuntimeHelpers.GetHashCode(this));
s.Write(chunk, 0, chunk.Length);
}
}
OutputStreams.Add(s);
Trace.TraceInformation("AddStream() : Add stream for {0}", RuntimeHelpers.GetHashCode(this));
}
}
public void AddStream(Stream newStream) { if (DataStream == null) { DataStream = new RecordTakingOutputStream(); DataStream.AddStream(newStream, true); return; } if (sendThread != null) { while (sendQueue.Count > 0) { Thread.Sleep(10); } } lock (receiverLock) { lock (senderLock) { try { var uiDetach = new UIStatusHint() { IsDetached = true }; var uiAttach = new UIStatusHint() { IsDetached = false }; Serializer.SerializeWithLengthPrefix<GameDataPacket>(newStream, uiDetach, PrefixStyle.Base128); DataStream.AddStream(newStream, true); Serializer.SerializeWithLengthPrefix<GameDataPacket>(newStream, uiAttach, PrefixStyle.Base128); newStream.Flush(); } catch (Exception) { } } } }