/// <summary>
 /// Initializes a new instance of the ReliableUdpConnectionRecord
 /// to send message
 /// </summary>
 /// <param name="key">EndPoint and TransmissionId key</param>
 /// <param name="tcb">Connection control block. <see cref="ReliableUdpConnectionControlBlock"/></param>
 /// <param name="reliableUdpMessage"><see cref="ReliableUdpMessage"/> message to send.</param>
 /// <param name="cToken">CancellationToken</param>
 /// <param name="asyncResult"><see cref="AsyncResultSendMessage"/></param>
 /// <exception cref="ArgumentNullException"><paramref name="key"/> or <paramref name="tcb"/> is a null reference</exception>
 public ReliableUdpConnectionRecord(Tuple <EndPoint, Int32> key, ReliableUdpConnectionControlBlock tcb,
                                    ReliableUdpMessage reliableUdpMessage, CancellationToken cToken, AsyncResultSendMessage asyncResult)
     : this(key, tcb)
 {
     if (reliableUdpMessage == null)
     {
         throw new ArgumentNullException("reliableUdpMessage");
     }
     if (reliableUdpMessage.Body == null || reliableUdpMessage.Body.Length == 0)
     {
         throw new ArgumentNullException("reliableUdpMessage", "reliableUdpMessage.Body can not be null.");
     }
     CToken                      = cToken;
     this.AsyncResult            = asyncResult;
     this.ReliableUdpMessageType = reliableUdpMessage.Type;
     this.IsNoAnswerNeeded       = reliableUdpMessage.NoAsk;
     //RU: добавляем содержимое ReliableUdpMessage в словарь ReliableUdpConnectionControlBlock'a
     //EN: fills the array of outcoming message with message bytes
     this.OutcomingStream = Tcb.OutcomingStreams.GetOrAdd(key, reliableUdpMessage.Body);
     //RU: Расчитываем количество пакетов необходимых для отправки сообщения
     this.NumberOfPackets = (int)Math.Ceiling((double)((double)OutcomingStream.Length / (double)this.BufferSize));
     //RU: переключаем состояние на отправку первого пакета
     //EN: set initial state
     this.State = Tcb.States.FirstPacketSending;
 }
 /// <summary>
 /// Initializes a new instance of the ReliableUdpConnectionRecord
 /// </summary>
 /// <param name="key">EndPoint and TransmissionId key</param>
 /// <param name="tcb">Connection control block. <see cref="ReliableUdpConnectionControlBlock"/></param>
 private ReliableUdpConnectionRecord(Tuple <EndPoint, Int32> key, ReliableUdpConnectionControlBlock tcb)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     if (key.Item1 == null)
     {
         throw new ArgumentNullException("key", "EndPoint can not be null. No remoteClient is configured.");
     }
     if (tcb == null)
     {
         throw new ArgumentNullException("tcb");
     }
     PacketCounter           = 0;
     this.IsDone             = 0;
     this.Key                = key;
     this.Tcb                = tcb;
     this.WindowSize         = tcb.TransmittingWindowSize;
     this.BufferSize         = tcb.DefaultMaxPacketSize;
     this.TransmissionId     = key.Item2;
     this.RemoteClient       = (IPEndPoint)key.Item1;
     this.WindowControlArray = new int[this.WindowSize];
     this.LostPackets        = new int[this.WindowSize];
     this.ShortTimerPeriod   = tcb.ShortTimerPeriod;
     this.LongTimerPeriod    = tcb.LongTimerPeriod;
     this.LockerReceive      = new object();
 }
 /// <summary>
 /// Initializes a new instance of the ReliableUdpConnectionRecord
 /// to receive message
 /// </summary>
 /// <param name="key">EndPoint and TransmissionId key</param>
 /// <param name="tcb">Connection control block. <see cref="ReliableUdpConnectionControlBlock"/></param>
 /// <param name="reliableUdpMessageType">Type of message to receive</param>
 /// <exception cref="ArgumentNullException"><paramref name="key"/> or <paramref name="tcb"/> is a null reference</exception>
 public ReliableUdpConnectionRecord(Tuple <EndPoint, Int32> key, ReliableUdpConnectionControlBlock tcb,
                                    ReliableUdpMessageTypes reliableUdpMessageType)
     : this(key, tcb)
 {
     CToken = CancellationToken.None;
     this.ReliableUdpMessageType = reliableUdpMessageType;
     //set initial state
     State = Tcb.States.FirstPacketReceived;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the ReliableUdp 
 /// that listens for incoming messages 
 /// on the specified local IP address and port number.
 /// </summary>
 /// <param name="localAddress">An <see cref="IPAddress"/> that represents the local IP address.</param>
 /// <param name="port">The port on which to listen for incoming messages. Set 0 to get dynamically assigned port</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <exception cref="ObjectDisposedException"></exception>
 /// <exception cref="SocketException"></exception>
 /// <exception cref="System.Security.SecurityException"></exception>  
 public ReliableUdp(IPAddress localAddress, int port = 0)
 {
     if (port < 0)
       {
     throw new ArgumentOutOfRangeException("port", "port must be non-negative");
       }
       m_tcb = new ReliableUdpConnectionControlBlock();
       StartListener(new IPEndPoint(localAddress, port));
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the ReliableUdp
 /// that listens for incoming messages
 /// on the specified local IP address and port number.
 /// </summary>
 /// <param name="localAddress">An <see cref="IPAddress"/> that represents the local IP address.</param>
 /// <param name="port">The port on which to listen for incoming messages. Set 0 to get dynamically assigned port</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <exception cref="ObjectDisposedException"></exception>
 /// <exception cref="SocketException"></exception>
 /// <exception cref="System.Security.SecurityException"></exception>
 public ReliableUdp(IPAddress localAddress, int port = 0)
 {
     if (port < 0)
     {
         throw new ArgumentOutOfRangeException("port", "port must be non-negative");
     }
     m_tcb = new ReliableUdpConnectionControlBlock();
     StartListener(new IPEndPoint(localAddress, port));
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the ReliableUdp 
 /// that listens for incoming messages 
 /// on the specified local endpoint.
 /// </summary>
 /// <param name="localEndPoint">An IPEndPoint that represents the local endpoint to which to bind the listener</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <exception cref="ObjectDisposedException"></exception>
 /// <exception cref="SocketException"></exception>
 /// <exception cref="System.Security.SecurityException"></exception>  
 public ReliableUdp(IPEndPoint localEndPoint)
 {
     m_tcb = new ReliableUdpConnectionControlBlock();
       StartListener(localEndPoint);
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the ReliableUdp 
 /// </summary>
 public ReliableUdp()
 {
     m_tcb = new ReliableUdpConnectionControlBlock();
 }
 /// <summary>
 /// Initializes a new instance of the ReliableUdpConnectionRecord
 /// </summary>
 /// <param name="key">EndPoint and TransmissionId key</param>
 /// <param name="tcb">Connection control block. <see cref="ReliableUdpConnectionControlBlock"/></param>
 private ReliableUdpConnectionRecord(Tuple<EndPoint, Int32> key, ReliableUdpConnectionControlBlock tcb)
 {
     if (key == null)
       {
     throw new ArgumentNullException("key");
       }
       if (key.Item1 == null)
       {
     throw new ArgumentNullException("key", "EndPoint can not be null. No remoteClient is configured.");
       }
       if (tcb == null)
       {
     throw new ArgumentNullException("tcb");
       }
       PacketCounter = 0;
       this.IsDone = 0;
       this.Key = key;
       this.Tcb = tcb;
       this.WindowSize = tcb.TransmittingWindowSize;
       this.BufferSize = tcb.DefaultMaxPacketSize;
       this.TransmissionId = key.Item2;
       this.RemoteClient = (IPEndPoint) key.Item1;
       this.WindowControlArray = new int[this.WindowSize];
       this.LostPackets = new int[this.WindowSize];
       this.ShortTimerPeriod = tcb.ShortTimerPeriod;
       this.LongTimerPeriod = tcb.LongTimerPeriod;
       this.LockerReceive = new object();
 }
 /// <summary>
 /// Initializes a new instance of the ReliableUdpConnectionRecord
 /// to send message 
 /// </summary>
 /// <param name="key">EndPoint and TransmissionId key</param>
 /// <param name="tcb">Connection control block. <see cref="ReliableUdpConnectionControlBlock"/></param>
 /// <param name="reliableUdpMessage"><see cref="ReliableUdpMessage"/> message to send.</param>
 /// <param name="cToken">CancellationToken</param>
 /// <param name="asyncResult"><see cref="AsyncResultSendMessage"/></param>
 /// <exception cref="ArgumentNullException"><paramref name="key"/> or <paramref name="tcb"/> is a null reference</exception>
 public ReliableUdpConnectionRecord(Tuple<EndPoint, Int32> key, ReliableUdpConnectionControlBlock tcb,
                                ReliableUdpMessage reliableUdpMessage, CancellationToken cToken, AsyncResultSendMessage asyncResult)
     : this(key, tcb)
 {
     if (reliableUdpMessage == null)
       {
     throw new ArgumentNullException("reliableUdpMessage");
       }
       if (reliableUdpMessage.Body == null || reliableUdpMessage.Body.Length == 0)
       {
     throw new ArgumentNullException("reliableUdpMessage", "reliableUdpMessage.Body can not be null.");
       }
       CToken = cToken;
       this.AsyncResult = asyncResult;
       this.ReliableUdpMessageType = reliableUdpMessage.Type;
       this.IsNoAnswerNeeded = reliableUdpMessage.NoAsk;
       //RU: добавляем содержимое ReliableUdpMessage в словарь ReliableUdpConnectionControlBlock'a
       //EN: fills the array of outcoming message with message bytes
       this.OutcomingStream = Tcb.OutcomingStreams.GetOrAdd(key, reliableUdpMessage.Body);
       //RU: Расчитываем количество пакетов необходимых для отправки сообщения
       this.NumberOfPackets = (int) Math.Ceiling((double) ((double) OutcomingStream.Length/(double) this.BufferSize));
       //RU: переключаем состояние на отправку первого пакета
       //EN: set initial state
       this.State = Tcb.States.FirstPacketSending;
 }
 /// <summary>
 /// Initializes a new instance of the ReliableUdpConnectionRecord
 /// to receive message 
 /// </summary>
 /// <param name="key">EndPoint and TransmissionId key</param>
 /// <param name="tcb">Connection control block. <see cref="ReliableUdpConnectionControlBlock"/></param>
 /// <param name="reliableUdpMessageType">Type of message to receive</param>
 /// <exception cref="ArgumentNullException"><paramref name="key"/> or <paramref name="tcb"/> is a null reference</exception>
 public ReliableUdpConnectionRecord(Tuple<EndPoint, Int32> key, ReliableUdpConnectionControlBlock tcb,
                                ReliableUdpMessageTypes reliableUdpMessageType)
     : this(key, tcb)
 {
     CToken = CancellationToken.None;
       this.ReliableUdpMessageType = reliableUdpMessageType;
       //set initial state
       State = Tcb.States.FirstPacketReceived;
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the ReliableUdp
 /// that listens for incoming messages
 /// on the specified local endpoint.
 /// </summary>
 /// <param name="localEndPoint">An IPEndPoint that represents the local endpoint to which to bind the listener</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <exception cref="ObjectDisposedException"></exception>
 /// <exception cref="SocketException"></exception>
 /// <exception cref="System.Security.SecurityException"></exception>
 public ReliableUdp(IPEndPoint localEndPoint)
 {
     m_tcb = new ReliableUdpConnectionControlBlock();
     StartListener(localEndPoint);
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the ReliableUdp
 /// </summary>
 public ReliableUdp()
 {
     m_tcb = new ReliableUdpConnectionControlBlock();
 }