private void IncomingData(object?sender, IncomingDataEventArgs e)
        {
            Task.Run(async() =>
            {
                var context      = new DataTransferContext();
                string requestId = null;
                var obj          = JsonHelper.FromJsonStringStrongTyped <object>(e.Data);
                LogEnvironment.LogDebugEvent($"Message-Type: {obj.GetType()}", LogSeverity.Report);
                if (obj is Request req)
                {
                    obj       = req.Payload;
                    requestId = req.RequestId;
                    if (!string.IsNullOrEmpty(req.Identity))
                    {
                        context.Identity = JsonHelper.FromJsonStringStrongTyped <TransferIdentity>(req.Identity).ToIdentity();
                    }
                }
                else if (obj is Response rep)
                {
                    obj    = null;
                    var ok = waitingOperations.TryRemove(rep.RequestId, out var wait);
                    if (ok)
                    {
                        wait.ServerResponse.SetResult(rep.Payload);
                    }
                    else
                    {
                        throw new CommunicationException("The given operation is not open.");
                    }
                }

                if (obj != null)
                {
                    var evData = new ObjectReceivedEventArgs {
                        Value = obj, Context = context
                    };
                    OnObjectReceived(evData);
                    if (!string.IsNullOrEmpty(requestId) && outgoing != null)
                    {
                        await WriteAsync(new Response
                        {
                            RequestId = requestId,
                            Payload   = evData.Result
                        });
                    }
                    else if (evData.Result != null)
                    {
                        await WriteAsync(evData.Result);
                    }
                }
            });
        }
 protected virtual void OnObjectReceived(ObjectReceivedEventArgs e)
 {
     ObjectReceived?.Invoke(this, e);
 }