Ejemplo n.º 1
0
        public void PairCommand(string pluginId, IFixture fixture, [Frozen] Mock <ITouchPortalSocket> socket)
        {
            var pair   = new PairCommand(pluginId);
            var client = fixture.Create <TouchPortalClient>();

            client.SendCommand(pair);

            var parameter = socket.SendMessage_Parameter();

            StringAssert.Contains("\"pair\"", parameter);
            StringAssert.Contains(pluginId, parameter);
        }
Ejemplo n.º 2
0
        /// <inheritdoc cref="ITouchPortalClient" />
        bool ITouchPortalClient.Connect()
        {
            //Connect:
            _logger?.LogInformation("Connecting to TouchPortal.");
            var connected = _touchPortalSocket.Connect();

            if (!connected)
            {
                return(false);
            }

            //Pair:
            _logger?.LogInformation("Sending pair message.");
            var pairCommand = new PairCommand(_eventHandler.PluginId);
            var pairing     = SendCommand(pairCommand);

            if (!pairing)
            {
                return(false);
            }

            //Listen:
            _logger?.LogInformation("Create listener.");
            var listening = _touchPortalSocket.Listen();

            _logger?.LogInformation("Listener created.");
            if (!listening)
            {
                return(false);
            }

            //Waiting for InfoMessage:
            _infoWaitHandle.WaitOne(-1);
            _logger?.LogInformation("Received pair response.");

            return(_lastInfoEvent != null);
        }