static TcpMapClientWorker AddStartClient(TcpMapClient client)
        {
            var conn = new TcpMapClientWorker()
            {
                Client = client
            };

            lock (_clients)
                _clients.Add(conn);
            if (!client.IsDisabled)
            {
                conn.StartWork();
            }
            return(conn);
        }
        static public TcpMapClientWorker CreateClientWorker(TcpMapLicense lic, int serverPort)
        {
            TcpMapClient client = new TcpMapClient()
            {
                License = lic
            };

            client.Id         = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            client.IsDisabled = true;
            client.ServerHost = "servername";
            client.ServerPort = serverPort;
            client.ClientHost = "localhost";
            client.ClientPort = 80;
            string jsonfilepath = Path.Combine(DataFolder, "TcpMapClient_" + client.Id + ".json");

            File.WriteAllText(jsonfilepath, JsonSerializer.Serialize(client));
            return(AddStartClient(client));
        }
        static public void ReAddClient(TcpMapClient client)
        {
            string jsonfilepath = Path.Combine(DataFolder, "TcpMapClient_" + client.Id + ".json");

            File.WriteAllText(jsonfilepath, JsonSerializer.Serialize(client));
            TcpMapClientWorker clientWorker = null;

            lock (_clients)
            {
                clientWorker = _clients.Where(v => v.Client.Id == client.Id).FirstOrDefault();
                if (clientWorker != null)
                {
                    _clients.Remove(clientWorker);
                }
            }
            if (clientWorker != null)
            {
                clientWorker.Stop();
            }
            AddStartClient(client);
        }
Exemple #4
0
 public TcpMapClientSession(TcpMapClient client, string sid)
 {
     Client    = client;
     SessionId = sid;
 }
 public TcpMapClientSession(TcpMapClient client, string sid)
 {
     this.Client    = client;
     this.SessionId = sid;
 }