Ejemplo n.º 1
0
        static TcpMapConnectorWorker AddStartConnector(TcpMapConnector mapconnector)
        {
            var conn = new TcpMapConnectorWorker()
            {
                Connector = mapconnector
            };

            lock (_connectors)
                _connectors.Add(conn);
            conn.StartWork();
            return(conn);
        }
Ejemplo n.º 2
0
        static public TcpMapConnectorWorker CreateConnectorWorker(int port)
        {
            CheckPortAvailable(port);

            TcpMapConnector conn = new TcpMapConnector();

            conn.Id         = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            conn.LocalPort  = port;
            conn.ServerHost = "servername";
            conn.ServerPort = port;
            conn.IsDisabled = true;
            string jsonfilepath = Path.Combine(DataFolder, "TcpMapConnector_" + conn.Id + ".json");

            File.WriteAllText(jsonfilepath, JsonSerializer.Serialize(conn));
            return(AddStartConnector(conn));
        }
Ejemplo n.º 3
0
        static public void ReAddConnector(TcpMapConnector connector)
        {
            string jsonfilepath = Path.Combine(DataFolder, "TcpMapConnector_" + connector.Id + ".json");

            File.WriteAllText(jsonfilepath, JsonSerializer.Serialize(connector));
            TcpMapConnectorWorker connectorWorker = null;

            lock (_clients)
            {
                connectorWorker = _connectors.Where(v => v.Connector.Id == connector.Id).FirstOrDefault();
                if (connectorWorker != null)
                {
                    _connectors.Remove(connectorWorker);
                }
            }
            if (connectorWorker != null)
            {
                connectorWorker.Stop();
            }
            AddStartConnector(connector);
        }