Hello -
strange problem :
when I have a someone connected I get this replay :
"!re=.id=*1=port=serial0=channel=0=allowed-addresses=0.0.0.0/0=tcp-port=8271=protocol=raw=log-file==remote-address=10.0.0.60:49972=active=true=disabled=false"
which is good because I can know if someone connected
but when now one is connected I only get part of the replay
"!re=.id=*1=port=serial0=channel=0=allowed-addresses=0.0.0.0/0=tcp-port=8271=protocol=raw=log-file==disabled=false"
which is a problem…
so how can I know if someone is connected or not? shuld I take the length of the answer? ot the number of the “=” ?
or there is another better solution ?
- the code is in C# …
what whould you suggest ?
Thanks ,
You could check for the appearance of substring “=active=true”:
var connected = response.Contains("=active=true");
I suggest to use tik4net higher lever api:
void Main()
{
using (var conn = ConnectionFactory.OpenConnection(TikConnectionType.Api, "192.168.88.1", 8728, "admin", "password"))
{
var port = conn.LoadAll<RemoteAccess>().First();
var connected = port.Active;
}
}
[TikEntity("/port/remote-access", IncludeDetails = true)]
public class RemoteAccess
{
[TikProperty(".id")]
public string Id { get; private set; }
[TikProperty("active")]
public bool Active { get; private set; }
[TikProperty("port")]
public string Port { get; private set; }
[TikProperty("channel")]
public int Channel { get; private set; }
[TikProperty("allowed-addresses")]
public string AllowedAddresses { get; private set; }
[TikProperty("local-address")]
public string LocalAddress { get; private set; }
[TikProperty("tcp-port")]
public int TcpPort { get; private set; }
[TikProperty("protocol")]
public string Protocol { get; private set; }
[TikProperty("log-file")]
public string LogFile { get; private set; }
[TikProperty("remote-address")]
public string RemoteAddress { get; private set; }
}
I didn’t about using “Contains”…
which is the same as see the size of the answer
I’m using this - so Thanks ,!