Example #1
0
        private static void HandleInitialize(ClientInitialize msg)
        {
            try
            {
                var address = msg.Options[Globals.E4_SERVER_ADDRESS].String;
                var port    = Convert.ToInt32(msg.Options[Globals.E4_SERVER_PORT].Double);
                var e4id    = msg.Options[Globals.E4_ID].String;

                // reconnect according to provided options, closes current connection
                provider?.Close();

                provider = new EmpaticaProvider(address, port);
                provider.Initialize(e4id);

                Send(new ClientInitialized
                {
                    Modifications = new List <string>
                    {
                        Globals.EDA_ID,
                        Globals.HEART_RATE_ID,
                        Globals.TEMPERATURE_ID
                    }
                }.ToJson());
            }
            catch (Exception e)
            {
                // initialization failed
                Console.Error.WriteLineAsync(e.Message);

                provider = null;
                Send(new ClientInitialized {
                    Modifications = new List <string>()
                }.ToJson());
            }
        }
Example #2
0
        private static void HandleExecutionRequest(ExecutionStartRequest msg)
        {
            var length = TimeSpan.FromSeconds(Convert.ToDouble(msg.Length));

            EmpaticaProvider.ExecuteAsync(msg.ModificationId, length).ConfigureAwait(false);
        }