// notifies cancellation (via the progress callback) for all // messages that have complete frames in the given list private void notifyCancellation(IList <OutgoingFrame> frames) { foreach (OutgoingFrame frame in frames) { if (frame.byteCount == frame.totalByteCount) { // this is the last frame for the given message MessageProgressCallback callback = frame.messageProgressCallback; if (callback != null) { callback.progress(0, 0); } } } }
internal virtual void doSomeOutput() { OutgoingFrame frame; lock (outgoingFrames) { if (outgoingFrames.Count == 0) { return; } frame = outgoingFrames[0]; if (frame.closeFlag) { outgoingFrames.RemoveAt(0); // this artificial exception forces the worker to // physically close this connection and remove it // from the set of channels throw new YAMIIOException("dummy"); } } if (connection.connectedChannel != null) { // TCP connection int sent = connection.connectedChannel.Send(frame.BuffersToSent); frame.AddSentBytes(sent); } else if (connection.ssl != null) { // TCP SSL connection int sent = connection.writingQueue.PutMany(frame.BuffersToSent); frame.AddSentBytes(sent); } else { // UDP connection connection.datagramChannel.SendTo( frame.SingleBuffer, connection.targetAddress); } if (frame.buffersConsumed()) { // the first frame (head in the queue) was complmesetely // sent -> notify its progress callback and remove // the head from the queue lock (outgoingFrames) { outgoingFrames.RemoveAt(0); } MessageProgressCallback callback = frame.messageProgressCallback; if (callback != null) { callback.progress(frame.byteCount, frame.totalByteCount); } if (logCallback != null) { if (logLevel == LogEventArgs.LogLevel.HIGH) { logCallback.Log(LogEventArgs.LogLevel.HIGH, "Frame sent:" + " target: " + target + " tid: " + frame.transportId + " fid: " + frame.frameNumber + " size: " + frame.byteCount + "/" + frame.totalByteCount); } } } }