public override void Init(ConnUri uri, bool persistent, string ID, int inactivityMS, int _sendGap = 0) { if ((uri == null || !uri.IsValid) && !tcpClientProvided) { return; } messageCircularBuffer = new CircularByteBuffer4Comms(65536); MINIMUM_SEND_GAP = _sendGap; RECEIVE_TIMEOUT = inactivityMS; frameWrapper?.SetID(ID); CommsUri = uri ?? CommsUri; SetIPChunks(CommsUri.IP); if (!tcpClientProvided) { tcpEq = new CommEquipmentObject <TcpClient>(ID, uri, null, persistent); tcpEq.ID = ID; receiverTask = new Task(Connect2EquipmentCallback, TaskCreationOptions.LongRunning); } else { tcpEq.ID = ID; receiverTask = new Task(ReceiveCallback, TaskCreationOptions.LongRunning); } senderTask = new Task(DoSendStart, TaskCreationOptions.LongRunning); }
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); }