Exemplo n.º 1
0
        public static DisposeInstanceRequest Deserialize(string message)
        {
            var result  = new DisposeInstanceRequest();
            var parsers = new Queue <Action <string> >(
                new Action <string>[]
            {
                s => result.CallId     = long.Parse(s),
                s => result.InstanceId = long.Parse(s)
            });

            CSVSerializer.Deserialize(Prefix, message, parsers);

            return(result);
        }
Exemplo n.º 2
0
        private void OnMessage(object sender, string rawMessage)
        {
            if (rawMessage.StartsWith(MessagePrefix) == false)
            {
                return;
            }

            if (InitInstanceRequest.CanDeserialize(rawMessage))
            {
                InitInstance(rawMessage);
                return;
            }

            if (DisposeInstanceRequest.CanDeserialize(rawMessage))
            {
                DisposeInstance(rawMessage);
                return;
            }
        }
Exemplo n.º 3
0
        public DisposeResult DisposeInstance(DisposeInstanceRequest request)
        {
            if (!instances.TryGetValue(request.InstanceId, out var instanceWrapper))
            {
                return(new DisposeResult
                {
                    CallId = request.CallId,
                    InstanceId = request.InstanceId,
                    IsSuccess = false
                });
            }

            try
            {
                instanceWrapper.Dispose();

                instances.Remove(request.InstanceId);
                return(new DisposeResult {
                    InstanceId = request.InstanceId,
                    CallId = request.CallId,
                    IsSuccess = true
                });
            }
            catch (Exception e)
            {
                return(new DisposeResult
                {
                    CallId = request.CallId,
                    InstanceId = request.InstanceId,
                    IsSuccess = false,
                    Exception = e,
                    ExceptionMessage = e.Message,
                    FullExceptionString = e.ToString()
                });
            }
        }
Exemplo n.º 4
0
        public void DisposeInstance(string message)
        {
            var result = DisposeInstance(DisposeInstanceRequest.Deserialize(message));

            MessageService.PostMessage(result.Serialize());
        }