Ejemplo n.º 1
0
        //channel created event.
        void ChannelCreated(object sender, LightSingleArgEventArgs <ITransportChannel> e)
        {
            IMessageTransportChannel <MetadataContainer> msgChannel = new MessageTransportChannel <MetadataContainer>((IRawTransportChannel)e.Target, _protocolStack);
            IServerConnectionAgent <MetadataContainer>   agent      = new MetadataConnectionAgent(msgChannel, _transactionManager);

            _scheduler.Regist(agent);
        }
Ejemplo n.º 2
0
        internal static void ChannelCreated(object sender, LightSingleArgEventArgs <ITransportChannel> e)
        {
            IHostTransportChannel hostChannel = (IHostTransportChannel)sender;
            KAENetworkResource    tag         = (KAENetworkResource)hostChannel.Tag;

            if (tag.Protocol == ProtocolTypes.Metadata)
            {
                IMessageTransportChannel <MetadataContainer> msgChannel = new MessageTransportChannel <MetadataContainer>((IRawTransportChannel)e.Target, (IProtocolStack)NetworkHelper.GetProtocolStack(tag.Protocol));
                MetadataConnectionAgent agent = new MetadataConnectionAgent(msgChannel, (MetadataTransactionManager)NetworkHelper.GetTransactionManager(tag.Protocol));
                agent.Disconnected   += AgentDisconnected;
                agent.NewTransaction += MetadataNewTransactionHandler;
                agent.Tag             = tag;
            }
            else if (tag.Protocol == ProtocolTypes.Intellegence)
            {
                IMessageTransportChannel <BaseMessage> msgChannel = new MessageTransportChannel <BaseMessage>((IRawTransportChannel)e.Target, (IProtocolStack)NetworkHelper.GetProtocolStack(tag.Protocol));
                IntellectObjectConnectionAgent         agent      = new IntellectObjectConnectionAgent(msgChannel, (MessageTransactionManager)NetworkHelper.GetTransactionManager(tag.Protocol));
                agent.Disconnected   += AgentDisconnected;
                agent.NewTransaction += IntellegenceNewTransactionHandler;
                agent.Tag             = tag;
            }
        }
Ejemplo n.º 3
0
        static void MetadataNewTransaction(object sender, LightSingleArgEventArgs <IMessageTransaction <MetadataContainer> > e)
        {
            MetadataConnectionAgent agent = (MetadataConnectionAgent)sender;
            IMessageTransaction <MetadataContainer> transaction = e.Target;
            MetadataContainer reqMsg = transaction.Request;
            Tuple <KAENetworkResource, ApplicationLevel> tag = new Tuple <KAENetworkResource, ApplicationLevel>((KAENetworkResource)agent.Tag, (reqMsg.IsAttibuteExsits(0x05) ? (ApplicationLevel)reqMsg.GetAttributeAsType <byte>(0x05) : ApplicationLevel.Stable));
            MessageIdentity     reqMsgIdentity      = reqMsg.GetAttributeAsType <MessageIdentity>(0x00);
            TransactionIdentity transactionIdentity = reqMsg.GetAttributeAsType <TransactionIdentity>(0x01);
            Guid uniqueId = reqMsg.GetAttributeAsType <Guid>(0x03);

            /*
             * We always makes a checking on the Metadata protocol network communication.
             * Because all of ours internal system communications are constructed by this kind of MSG protocol.
             */
            if (reqMsgIdentity.ProtocolId >= 0xFC)
            {
                HandleSystemCommand(transaction);
            }
            //sends it to the appropriate application.
            else
            {
                HandleBusiness(tag, (MetadataMessageTransaction)transaction, reqMsgIdentity, reqMsg, uniqueId, transactionIdentity);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 ///    创建一个新的服务器端连接代理器,并将其注册到当前的连接池中
 /// </summary>
 /// <param name="iep">要创建连接的远程终结点地址</param>
 /// <param name="protocolStack">协议栈</param>
 /// <param name="transactionManager">网络事务管理器</param>
 /// <returns>返回已经创建好的服务器端连接代理器</returns>
 protected override IServerConnectionAgent <MetadataContainer> CreateAgent(IPEndPoint iep, IProtocolStack protocolStack, object transactionManager)
 {
     return(MetadataConnectionAgent.Create(iep, protocolStack, (MetadataTransactionManager)transactionManager));
 }