protected override void CoreInnerStop() { if (_hostChannel == null) { return; } _hostChannel.ChannelCreated -= ChannelCreated; _hostChannel = null; _scheduler.DistoryDynamicCounters(); _scheduler = null; _tracing.Info(" #Stop CoinAPI::BasicBusinessComponent succeed!"); }
protected override void CoreInnerStart() { int port = int.Parse(SystemWorker.Instance.ConfigurationProxy.GetField("CoinAPI", "ServicePort")); _tracing.Info(" #Get client-port config succeed, port: " + port); Console.WriteLine(" #Get client-port config succeed, port: " + port); _hostChannel = new TcpHostTransportChannel(port); _tracing.Info(" #Initialize TCP host channel succeed!"); Console.WriteLine(" #Initialize TCP host channel succeed!"); if (!_hostChannel.Regist()) { _tracing.Critical(" #Regist TCP port {0} failed!", port); Console.WriteLine(string.Format(" #Regist TCP port {0} failed!", port)); throw new Exception(string.Format(" #Regist TCP port {0} failed!", port)); } _tracing.Info(" #Regist TCP host channel succeed!"); Console.WriteLine(" #Regist TCP host channel succeed!"); _hostChannel.ChannelCreated += ChannelCreated; }
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; } }