Пример #1
0
        private async Task ParseClientToServerMessage(CoreComMessage request)
        {
            //this only hapend after first messages bin sent
            if (request.MessageSignature == CoreComInternalSignatures.CoreComInternal_PullQueue)
            {
                await ParseCoreComFrameworkMessage(request);

                return;
            }



            CoreComUserInfo coreComUserInfo = new CoreComUserInfo {
                ClientId = request.ClientId
            };

            if (string.IsNullOrEmpty(request.JsonObject))
            {
                CoreComMessagingCenter.Send(request.MessageSignature, coreComUserInfo);
            }
            else
            {
                var objectDeser = JsonSerializer.Deserialize(request.JsonObject, CoreComMessagingCenter.GetMessageArgType(request.MessageSignature));

                CoreComMessagingCenter.Send(request.MessageSignature, coreComUserInfo, objectDeser);
            }
        }
Пример #2
0
        private async Task ParseServerToClientMessage(CoreComMessageResponse request)
        {
            using (var dbContext = new CoreComContext(_dbContextOptions))
            {
                request.TransferStatus = (int)TransferStatusEnum.Recived;
                request.RecivedUtc     = Helpers.DateTimeConverter.DateTimeUtcNowToUnixTime();

                if (request.MessageSignature == CoreComInternalSignatures.CoreComInternal_PullQueue)
                {
                    await ParseCoreComFrameworkFromServerMessage(request).ConfigureAwait(false);

                    LogEventOccurred(dbContext, request);
                    return;
                }



                LogEventOccurred(dbContext, request);
                //System.Type type = Type.GetType(request.JsonObjectType);
                // erer = new CoreComMessagingCenter();
                Type type = CoreComMessagingCenter.GetMessageArgType(request.MessageSignature);
                if (type == null)
                {
                    CoreComMessagingCenter.Send(request.MessageSignature, null);
                }
                else
                {
                    var objectDeser = JsonSerializer.Deserialize(request.JsonObject, type);
                    CoreComMessagingCenter.Send(request.MessageSignature, null, objectDeser);
                }
                //CoreComUserInfo coreComUserInfo = new CoreComUserInfo { ClientId = request.ClientId };
                //if (string.IsNullOrEmpty(request.JsonObject))
                //{
                //    var funcToRun = _receiveDelegatesOneParm.FirstOrDefault(x => x.Item2 == request.MessageSignature);
                //    if (funcToRun != null)
                //    {
                //        await funcToRun.Item1.Invoke(coreComUserInfo).ConfigureAwait(false);
                //    }
                //    else
                //    {
                //        LogErrorOccurred("No function mapped to " + request.MessageSignature, request);
                //    }
                //}
                //else
                //{
                //    var funcToRun = _receiveDelegatesTwoParm.FirstOrDefault(x => x.Item2 == request.MessageSignature);
                //    if (funcToRun != null)
                //    {
                //        var objectDeser = JsonSerializer.Deserialize(request.JsonObject, funcToRun.Item3);
                //        await funcToRun.Item1.Invoke(objectDeser, coreComUserInfo).ConfigureAwait(false);
                //    }
                //    else
                //    {
                //        LogErrorOccurred("No function mapped to " + request.MessageSignature, request);
                //    }
                //}
            }
        }