Exemplo n.º 1
0
        //private MemoryPool<byte> memoryPool = KestrelMemoryPool.Create();
        #endregion


        public IPSocketCommunicator(FrameWrapperBase <T> _frameWrapper = null) : base()
        {
            frameWrapper   = _frameWrapper;
            clientProvided = false;

            State = STATE.STOP;
        }
Exemplo n.º 2
0
        public TCPNETCommunicatorv2(TcpClient client, FrameWrapperBase <T> _frameWrapper = null) : base()
        {
            frameWrapper = _frameWrapper != null ? _frameWrapper : null;
            // Do stuff
            tcpClientProvided = true;
            var IP   = (client.Client.RemoteEndPoint as IPEndPoint).Address.ToString();
            var Port = (client.Client.RemoteEndPoint as IPEndPoint).Port;

            CommsUri = new ConnUri($"tcp://{IP}:{Port}");

            tcpEq = new CommEquipmentObject <TcpClient>("", CommsUri, client, false);
        }
Exemplo n.º 3
0
        public TCPNETCommunicator(Socket client, FrameWrapperBase <T> _frameWrapper = null) : base()
        {
            frameWrapper = _frameWrapper;

            // Do stuff
            tcpClientProvided = true;
            var IP   = (client.RemoteEndPoint as IPEndPoint).Address.ToString();
            var Port = (client.RemoteEndPoint as IPEndPoint).Port;

            CommsUri = new ConnUri($"tcp://{IP}:{Port}");

            // When clint provided, persistent is forced false
            persistent = false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates an ICommunicator
        /// </summary>
        /// <typeparam name="T">Base data type used by the serialilzer/framewrapper. If not using serializer, put object</typeparam>
        /// <param name="uri">ConnUri defining the connection</param>
        /// <param name="frameWrapper">Serializer/Framewrapper that will be used. It can be null if not used</param>
        /// <param name="circular">Use internal CircularBuffer if you do not own the byte array passed to SendASync and do not have control over its lifespan. It is not used in SendSync</param>
        /// <returns>Created ICommunicator. It still needs to be initialized and started</returns>
        public static ICommunicator CreateCommunicator <T>(ConnUri uri, FrameWrapperBase <T> frameWrapper, bool circular = false)
        {
            ICommunicator c = null;

            switch (uri.UriType)
            {
            case ConnUri.TYPE.TCP:
                c = new TCPNETCommunicator <T>(frameWrapper, circular);
                break;

            case ConnUri.TYPE.UDP:
                c = new UDPNETCommunicator <T>(frameWrapper, circular);
                break;
            }

            return(c);
        }
Exemplo n.º 5
0
        public IPSocketCommunicator(Socket client, FrameWrapperBase <T> _frameWrapper = null) : base()
        {
            frameWrapper   = _frameWrapper;
            socket         = client;
            clientProvided = true;

            // Do stuff
            var IP   = (client.RemoteEndPoint as IPEndPoint).Address.ToString();
            var Port = (client.RemoteEndPoint as IPEndPoint).Port;

            CommsUri = new ConnUri($"{(client.ProtocolType == ProtocolType.Tcp ? "tcp" : "udp")}://{IP}:{Port}");
            IPUInt   = HelperTools.IP2UInt(IP);

            // When client provided, persistent is forced false
            persistent = false;

            State = CommunicatorBase <T> .STATE.STOP;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates an ICommunicator
        /// </summary>
        /// <typeparam name="T">Base data type used by the serialilzer/framewrapper. If not using serializer, put object</typeparam>
        /// <param name="uri">string uri defining the connection</param>
        /// <param name="frameWrapper">Serializer/Framewrapper that will be used. It can be null if not used</param>
        /// <param name="circular">Use internal CircularBuffer if you do not own the byte array passed to SendASync and do not have control over its lifespan. It is not used in SendSync</param>
        /// <returns>Created ICommunicator. It still needs to be initialized and started</returns>
        public static ICommunicator CreateCommunicator <T>(string uriString, FrameWrapperBase <T> frameWrapper, bool circular = false)
        {
            ICommunicator c   = null;
            var           uri = new ConnUri(uriString);

            if (!uri.IsValid)
            {
                return(null);
            }

            switch (uri.UriType)
            {
            case ConnUri.TYPE.TCP:
                c = new TCPNETCommunicator <T>(frameWrapper, circular);
                break;

            case ConnUri.TYPE.UDP:
                c = new UDPNETCommunicator <T>(frameWrapper, circular);
                break;
            }

            return(c);
        }
Exemplo n.º 7
0
 public TCPNETCommunicatorv2(FrameWrapperBase <T> _frameWrapper = null) : base()
 {
     frameWrapper      = _frameWrapper != null ? _frameWrapper : null;
     tcpClientProvided = false;
 }
Exemplo n.º 8
0
 public TCPNETCommunicator(FrameWrapperBase <T> _frameWrapper = null, bool circular = false) : base()
 {
     frameWrapper      = _frameWrapper != null ? _frameWrapper : null;
     tcpClientProvided = false;
     useCircular       = circular;
 }