Ejemplo n.º 1
0
        private void ProcessLine(ReadOnlySequence <byte> line)
        {
            if (line.Length == 0)
            {
                return;
            }

            var result = line.ParseAsUTF8String();

            try {
                var responseModel = JsonConvert.DeserializeObject <TPResponseBase>(result);

                switch (responseModel.Type.ToLower().Trim())
                {
                case "info":
                    HandlePairEvent(JsonConvert.DeserializeObject <PairResponse>(result));
                    break;

                case "action":
                    HandleActionEvent(JsonConvert.DeserializeObject <TPAction>(result));
                    break;

                case "listchange":
                    HandleListChangeEvent(JsonConvert.DeserializeObject <TPListChange>(result));
                    break;

                case "closeplugin":
                    HandleCloseEvent(JsonConvert.DeserializeObject <TPClosePlugin>(result));
                    break;
                }
            } catch (Exception err) {
                Console.WriteLine($"Exception - {err.Message}");
            }
        }