Ejemplo n.º 1
0
        // 开启客户端
        private void StartClient()
        {
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            IDictionary props = new Hashtable();

            props["port"] = 0;
            TcpChannel channel = new TcpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(channel);

            //// 配置通道及传输格式
            //string cfg = "Client.config";
            //RemotingConfiguration.Configure(cfg);

            // 由config中读取相关数据
            string broadCastObjURL = ConfigurationManager.AppSettings["BroadCastObjURL"];

            // 获取广播远程对象
            watch = (IBroadCast)Activator.GetObject(typeof(IBroadCast), broadCastObjURL);

            wrapper = new EventWrapper();
            wrapper.LocalBroadCastEvent += new BroadCastEventHandler(BroadCastingMessage);
            watch.BroadCastEvent        += new BroadCastEventHandler(wrapper.BroadCasting);
            SetSubscribe(true);
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            BinaryServerFormatterSinkProvider serverProvider = new
                                                               BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider = new
                                                               BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            IDictionary props = new Hashtable();

            props["port"] = 0;
            HttpChannel channel = new HttpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(channel, false);

            watch = (IBroadCast)Activator.GetObject(
                typeof(IBroadCast), "http://localhost:8080/BroadCastMessage.soap");

            wrapper = new EventWrapper();
            wrapper.LocalBroadCastEvent += new BroadCastEventHandler(BroadCastingMessage);
            watch.BroadCastEvent        += new BroadCastEventHandler(wrapper.BroadCasting);

            //watch.BroadCastEvent += new BroadCastEventHandler(BroadCastingMessage);
        }
Ejemplo n.º 3
0
        public void StartClient()
        {
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            IDictionary props = new Hashtable();

            props["port"] = 0;
            TcpChannel channel = new TcpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(channel);

            // 由config中读取相关数据
            string broadCastObjURL = ConfigurationManager.AppSettings["BroadCastObjURL"];
            string upCastObjURL    = ConfigurationManager.AppSettings["RobotUpCastObjURL"];

            // 获取广播远程对象
            watch   = (IBroadCast)Activator.GetObject(typeof(IBroadCast), broadCastObjURL);
            wrapper = new EventWrapper();
            wrapper.LocalBroadCastEvent += new BroadCastEventHandler(broadCastHandler.OnBroadCastingInfo);
            watch.BroadCastEvent        += new BroadCastEventHandler(wrapper.BroadCasting);

            // upcast
            upCast = (IUpCast)Activator.GetObject(typeof(IUpCast), upCastObjURL);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// BroadCastHub class
        /// </summary>
        public BroadCastHub(IBroadCast broadCast)
        {
            if (broadCast == null)
            {
                throw new ArgumentNullException("BroadCast object is null !");
            }

            BeginBroadCast(broadCast); // This will avoid an explicit call to initialize a hub by message broadcaster client
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Begin broadCast message
        /// </summary>
        /// <param name="broadCast">IBroadCast value</param>
        private void BeginBroadCast(IBroadCast broadCast)
        {
            // Register/Attach broadcast listener event
            broadCast.MessageListened += (sender, broadCastArgs)
                                         =>
            {
                RegisterMessageEvents(broadCastArgs);
            };

            // Unregister/detach broadcast listener event
            broadCast.MessageListened -= (sender, broadCastArgs)
                                         =>
            {
                RegisterMessageEvents(broadCastArgs);
            };
        }
 /// <summary>
 /// Message broadcaster ApiController class
 /// </summary>
 /// <param name="broadCast">IBroadCast value</param>
 public MessageBroadCastController(IBroadCast broadCast)
 {
     _broadCast = broadCast;
 }