コード例 #1
0
        private  void RegisterClient()
        {
            if ((this._client != null))
            {
                (this._client as IClientChannel).Abort();
                this._client = null;
            }

            BroadcastorCallback cb = new BroadcastorCallback();
            cb.SetHandler(this.HandleBroadcast);

            InstanceContext context =new InstanceContext(cb);

            var proxy=new DuplexChannelFactory<IBroadcastorService>(context,"NetTcpBinding_IBroadcastorService");
            this._client = proxy.CreateChannel();
                

            this._client.RegisterClient(this.txt_ClientName.Text);
        }
コード例 #2
0
        public ServiceChannel()
        {
            if (dualFactory == null)
            {
                curChannelState = CHANNELSTATE.UNINITIALISED;

                subscribers = new Dictionary <MSGTYPE, EventHandler>();

                endpoint = new EndpointAddress("http://192.168.1.222:584/BroadcastorService");
                bc       = new BroadcastorCallback();
                bc.SetHandler(this.HandleBroadcast);
                dualFactory = new DuplexChannelFactory <IBroadcastorService>(bc, new WSDualHttpBinding()
                {
                    CloseTimeout = new TimeSpan(0, 0, 10)
                }, endpoint);
                channel = dualFactory.CreateChannel();

                bgwOnlineWatcher = new BackgroundWorker();
                bgwOnlineWatcher.WorkerReportsProgress = true;
                bgwOnlineWatcher.DoWork          += BgwOnlineWatcher_DoWork;
                bgwOnlineWatcher.ProgressChanged += BgwOnlineWatcher_ProgressChanged;
            }
        }
コード例 #3
0
        private void DuplexSample()
        {
            EndpointAddress endpoint = new EndpointAddress("http://192.168.1.222:584/BroadcastorService");

            BroadcastorCallback bc = new BroadcastorCallback();

            bc.SetHandler(this.HandleBroadcast);

            DuplexChannelFactory <IBroadcastorService> dualFactory =
                new DuplexChannelFactory <IBroadcastorService> (bc, new WSDualHttpBinding(), endpoint);
            IBroadcastorService channel = dualFactory.CreateChannel();

            Msg result = channel.RegisterClient(new Msg()
            {
                ClientName = "Client_1", GUID = new Guid()
            });

            Debug.Print($"{result.MsgStatus}");

            channel.NotifyServer(new Msg()
            {
                ClientName = "client_1", GUID = new Guid(), MsgTypeIn = MSGTYPE.WATCHONLINE
            });
        }