Beispiel #1
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);
        }
Beispiel #2
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);
        }