| | | 1 | | using System.Globalization; |
| | | 2 | | |
| | | 3 | | namespace Renci.SshNet.Messages.Connection |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Base class for all channel specific SSH messages. |
| | | 7 | | /// </summary> |
| | | 8 | | public abstract class ChannelMessage : Message |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gets or sets the local channel number. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <value> |
| | | 14 | | /// The local channel number. |
| | | 15 | | /// </value> |
| | 274730 | 16 | | public uint LocalChannelNumber { get; protected set; } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets the size of the message in bytes. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <value> |
| | | 22 | | /// The size of the messages in bytes. |
| | | 23 | | /// </value> |
| | | 24 | | protected override int BufferCapacity |
| | | 25 | | { |
| | | 26 | | get |
| | 41310 | 27 | | { |
| | 41310 | 28 | | var capacity = base.BufferCapacity; |
| | 41310 | 29 | | capacity += 4; // LocalChannelNumber |
| | 41310 | 30 | | return capacity; |
| | 41310 | 31 | | } |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Initializes a new instance of the <see cref="ChannelMessage"/> class. |
| | | 36 | | /// </summary> |
| | 45883 | 37 | | protected ChannelMessage() |
| | 45883 | 38 | | { |
| | 45883 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Initializes a new instance of the <see cref="ChannelMessage"/> class with the specified local channel number |
| | | 43 | | /// </summary> |
| | | 44 | | /// <param name="localChannelNumber">The local channel number.</param> |
| | 42695 | 45 | | protected ChannelMessage(uint localChannelNumber) |
| | 42695 | 46 | | { |
| | 42695 | 47 | | LocalChannelNumber = localChannelNumber; |
| | 42695 | 48 | | } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Called when type specific data need to be loaded. |
| | | 52 | | /// </summary> |
| | | 53 | | protected override void LoadData() |
| | 45880 | 54 | | { |
| | 45880 | 55 | | LocalChannelNumber = ReadUInt32(); |
| | 45880 | 56 | | } |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Called when type specific data need to be saved. |
| | | 60 | | /// </summary> |
| | | 61 | | protected override void SaveData() |
| | 41310 | 62 | | { |
| | 41310 | 63 | | Write(LocalChannelNumber); |
| | 41310 | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Returns a <see cref="string"/> that represents this instance. |
| | | 68 | | /// </summary> |
| | | 69 | | /// <returns> |
| | | 70 | | /// A <see cref="string"/> that represents this instance. |
| | | 71 | | /// </returns> |
| | | 72 | | public override string ToString() |
| | 87181 | 73 | | { |
| | 87181 | 74 | | return string.Format(CultureInfo.CurrentCulture, "{0} : #{1}", base.ToString(), LocalChannelNumber); |
| | 87181 | 75 | | } |
| | | 76 | | } |
| | | 77 | | } |