Exemple #1
0
        public override void Init(ConnUri uri, bool persistent, string ID, int inactivityMS, int _sendGap = 0)
        {
            if ((uri == null || !uri.IsValid) && !tcpClientProvided)
            {
                return;
            }

            this.ID          = ID;
            messageQueu      = useCircular ? (ICommsQueue) new CircularByteBuffer4Comms(65536) : (ICommsQueue) new BlockingByteQueue();
            MINIMUM_SEND_GAP = _sendGap;
            RECEIVE_TIMEOUT  = inactivityMS;
            frameWrapper?.SetID(ID);
            State = STATE.STOP;

            CommsUri = uri ?? CommsUri;
            SetIPChunks(CommsUri.IP);

            if (!tcpClientProvided)
            {
                tcpEq    = new CommEquipmentObject <TcpClient>(ID, uri, null, persistent);
                tcpEq.ID = ID;
            }
            else
            {
                tcpEq.ID = ID;
            }
        }
Exemple #2
0
        public TCPNETCommunicator(TcpClient client, FrameWrapperBase <T> _frameWrapper = null, bool circular = false) : 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);

            useCircular = circular;
        }