Example #1
0
 protected override IInstruction BuildInstruction(DuplexMessage commandMessage)
 {
     var instrSet = new InstructionSet(this);
     using (var scope = ObjectHost.Host.BeginLifetimeScope())
     {
         instrSet.AddInstruction(scope.Resolve<CheckInQueryInstruction>(
             new NamedParameter("command", this),
             new NamedParameter("parameter", commandMessage.GetContent<object>())));
         instrSet.AddInstruction(scope.Resolve<CheckInReplyInstruction>(
             new NamedParameter("parameter", commandMessage.GetContent<object>())));
     }
     return instrSet;
 }
Example #2
0
        protected override IInstruction BuildInstruction(DuplexMessage commandMessage)
        {
            var instrSet = new InstructionSet(this);

            using (var scope = ObjectHost.Host.BeginLifetimeScope())
            {
                instrSet.AddInstruction(scope.Resolve <CheckInQueryInstruction>(
                                            new NamedParameter("command", this),
                                            new NamedParameter("parameter", commandMessage.GetContent <object>())));
                instrSet.AddInstruction(scope.Resolve <CheckInReplyInstruction>(
                                            new NamedParameter("parameter", commandMessage.GetContent <object>())));
            }
            return(instrSet);
        }
Example #3
0
        bool UpdateRegisterInfo(School school, DuplexMessage commandMessage)
        {
            var registerOk   = false;
            var registerInfo = commandMessage.GetContent <RegisterInfo>();

            if (registerInfo != null)
            {
                school.ClientPubKey = registerInfo.ClientPubKey;
                school.UniqueToken  = registerInfo.ClientMacAddr;
                metaRepository.AddOrUpdateSchool(school, (updateOk) =>
                {
                    DuplexMessage resultMessage;
                    if (updateOk)
                    {
                        resultMessage = DuplexMessage.CreateCallbackMessage(commandMessage);
                    }
                    else
                    {
                        resultMessage = DuplexMessage.CreateCallbackMessage(commandMessage, ErrorCode.RegisterFailed);
                    }

                    Return(resultMessage);
                });
                registerOk = true;
            }
            return(registerOk);
        }
Example #4
0
        protected override DuplexMessage DoExecute(DuplexMessage commandMessage)
        {
            Log.Error(ErrorCode.BadProtocalVersion, new Exception("error"));
            var content = commandMessage.GetContent <Customer>();

            return(DuplexMessage.CreateCallbackMessage(commandMessage, content));
        }
Example #5
0
        bool UpdateRegisterInfo(School school, DuplexMessage commandMessage)
        {
            var registerOk = false;
            var registerInfo = commandMessage.GetContent<RegisterInfo>();
            if (registerInfo != null)
            {
                school.ClientPubKey = registerInfo.ClientPubKey;
                school.UniqueToken = registerInfo.ClientMacAddr;
                metaRepository.AddOrUpdateSchool(school, (updateOk) =>
                {
                    DuplexMessage resultMessage;
                    if (updateOk)
                        resultMessage = DuplexMessage.CreateCallbackMessage(commandMessage);
                    else
                        resultMessage = DuplexMessage.CreateCallbackMessage(commandMessage, ErrorCode.RegisterFailed);

                    Return(resultMessage);
                });
                registerOk = true;
            }
            return registerOk;
        }
Example #6
0
 protected override DuplexMessage DoExecute(DuplexMessage commandMessage)
 {
     Log.Error(ErrorCode.BadProtocalVersion, new Exception("error"));
     var content = commandMessage.GetContent<Customer>();
     return DuplexMessage.CreateCallbackMessage(commandMessage, content);
 }