Exemple #1
0
        /// <summary>
        /// Sends disconnect message
        /// </summary>
        private void SendDisconnect()
        {
            DisconnectTransation = RTransactionGenerator.GenerateId();
            RNetMessage disc = new RNetMessage(Encoding.UTF8.GetBytes("disconnect_request"), DisconnectTransation, RemoteEndPoint, RQoSType.Internal);

            _outgoingMsgQueue.Enqueue(disc);
        }
        /// <summary>
        /// Enqueues message in sending queue, uses own implementation of <see cref="RTransactionGenerator"/> if qosType is reliable.
        /// </summary>
        /// <param name="messageId"></param>
        /// <param name="data"></param>
        /// <param name="remoteEndPoint"></param>
        /// <param name="qosType"></param>
        public void Send(ref byte[] data, IPEndPoint remoteEndPoint, RQoSType qosType = RQoSType.Unrealiable)
        {
            if (data.Length == 0)
            {
                _logger?.WriteError(new LogInfo("Tried to send empty message."));
                return;
            }
            else if (remoteEndPoint == null)
            {
                _logger?.WriteError(new LogInfo("Could not send message to unknown endpoint."));
                return;
            }

            if (!_cts.Token.IsCancellationRequested)
            {
                RNetMessage message;
                switch (qosType)
                {
                default:
                case RQoSType.Realiable:
                case RQoSType.Internal:
                    message = new RNetMessage(data, RTransactionGenerator.GenerateId(), remoteEndPoint, qosType);
                    break;

                case RQoSType.Unrealiable:
                    message = new RNetMessage(data, null, remoteEndPoint, qosType);
                    break;
                }
                _outgoingMsgQueue.Enqueue(message);
            }
        }
Exemple #3
0
        /// <summary>
        /// Sends Discover Message
        /// </summary>
        private void SendHello()
        {
            DiscoverTransaction = RTransactionGenerator.GenerateId();

            Error += OnDiscoverFailed;

            RNetMessage discover = new RNetMessage(Encoding.UTF8.GetBytes("discover"), DiscoverTransaction, RemoteEndPoint, RQoSType.Internal);

            _outgoingMsgQueue.Enqueue(discover);
        }
Exemple #4
0
 public void DisconnectEndPoint(IPEndPoint ep)
 {
     if (!_pendingDisconnects.ContainsKey(ep))
     {
         RNetMessage disc = new RNetMessage(Encoding.UTF8.GetBytes("disconnect_request"), RTransactionGenerator.GenerateId(), ep, RQoSType.Internal);
         _pendingDisconnects.Add(ep, DateTime.Now);
         _outgoingMsgQueue.Enqueue(disc);
     }
 }