Exemplo n.º 1
0
        protected virtual Channel LookUpChannel()
        {
            Channel channel = ChannelServices.GetChannelById(this.ChannelId);

            if (channel == null)
            {
                // regisztrálás
                if (LOGGER.IsErrorEnabled)
                {
                    LOGGER.Error(string.Format("{0}, locator cannot find channel with id '{1}'. Create default channel.", LOG_PREFIX, this.ChannelId));
                }
                BinaryMessageSink   sink  = new BinaryMessageSink(true, 1024);
                List <IMessageSink> sinks = new List <IMessageSink>();
                sinks.Add(sink);

                TerraGrafNetworkFactory networkFactory = new TerraGrafNetworkFactory();

                DefaultServerStreamFactory serverStreamFactory = new DefaultServerStreamFactory();
                DefaultClientStreamFactory clientStreamFactory = new DefaultClientStreamFactory();

                channel = new TCPChannel(this.ChannelId, sinks, sinks, networkFactory, serverStreamFactory, clientStreamFactory);

                ChannelServices.RegisterChannel(channel);
            }

            return(channel);
        }
Exemplo n.º 2
0
        protected virtual Channel LookUpChannel()
        {
            Channel channel = ChannelServices.GetChannelById(this.ChannelId);

            if (channel == null)
            {
                // regisztrálás
                BinaryMessageSink   sink  = new BinaryMessageSink(true, 1024);
                List <IMessageSink> sinks = new List <IMessageSink>();
                sinks.Add(sink);

                AddressEndPoint        serverEndPoint = new AddressEndPoint("127.0.0.1", 0);
                List <AddressEndPoint> serverData     = new List <AddressEndPoint>();
                serverData.Add(serverEndPoint);

                TerraGrafNetworkFactory networkFactory = new TerraGrafNetworkFactory();

                DefaultServerStreamFactory serverStreamFactory = new DefaultServerStreamFactory();
                DefaultClientStreamFactory clientStreamFactory = new DefaultClientStreamFactory();

                channel = new TCPChannel(this.ChannelId, sinks, sinks, serverData, networkFactory, serverStreamFactory, clientStreamFactory);
                channel.StartListening();

                ChannelServices.RegisterChannel(channel);
            }

            return(channel);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 启动
        /// </summary>
        /// <param name="httpUrl"></param>
        /// <param name="Server1078"></param>
        /// <param name="Port1078"></param>
        /// <returns></returns>
        public static JTHClient Start(JTTask MyTask, string Key, string httpUrl, string Server1078, int Port1078)
        {
            var mth = regUrl.Match(httpUrl);

            if (!mth.Success)
            {
                return(null);
            }
            var ip   = mth.Groups[1].Value;
            var port = Convert.ToInt32(mth.Groups[2].Value);

            var jthc = new JTHClient();

            jthc.httpUrl      = httpUrl;
            jthc.HandShakeUrl = "/" + HttpUtility.UrlEncode(mth.Groups[3].Value);
            jthc.Server1078   = Server1078;
            jthc.Port1078     = Port1078;
            jthc.Key          = Key;
            jthc.MyTask       = MyTask;

            var channel = new TCPChannel(ip, port);

            jthc.channelhttp        = channel;
            channel.DataReceive     = jthc.Receive;
            channel.DataSend        = jthc.DataSend;
            channel.ChannelDispose += jthc.Http_ChannelDispose;
            channel.ChannelConnect += jthc.Http_ChannelConnect;
            channel.Connect();


            return(jthc);
        }
Exemplo n.º 4
0
        public static JT1078Client Start(JTHClient jtHttp, string Server1078, int Port1078)
        {
            JT1078Client jt1078 = new JT1078Client();

            jt1078.jtHttp = jtHttp;
            var channel = new TCPChannel(Server1078, Port1078);

            jt1078.channel1078      = channel;
            channel.DataReceive     = jt1078.Receive;
            channel.DataSend        = jt1078.DataSend;
            channel.ChannelDispose += jt1078.ChannelDispose;
            channel.ChannelConnect += jt1078.ChannelConnect;
            channel.Connect();
            return(jt1078);
        }