示例#1
0
        public async Task Connect()
        {
            if (gatewayState != GatewayState.Disconnected)
            {
                Disconnect();
            }

            SetGatewayState(GatewayState.ConnectingToPort);

            if (endlessConnectionAttempts)
            {
                while (gatewayState == GatewayState.ConnectingToPort)
                {
                    connectionPort.Connect();
                    await Task.Delay(1000);
                }
                while (gatewayState == GatewayState.ConnectingToGateway)
                {
                    await Task.Delay(1000);
                }
            }
            else
            {
                connectionPort.Connect();
            }
        }