コード例 #1
0
        public MSG RegisterClient()
        {
            MSG result = new MSG()
            {
                Code = CODES.SUCCESS, Text = string.Empty, Obj = null
            };

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

                curChannelState = CHANNELSTATE.CONNECTED;
            }
            catch (Exception exc)
            {
                curChannelState = CHANNELSTATE.UNINITIALISED;

                result.Code = CODES.ERROR;
                result.Text = "Неудалось зарегистрироваться на сервере.";
                result.Obj  = exc;
            }

            bgwOnlineWatcher.RunWorkerAsync();

            return(result);
        }
コード例 #2
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
            });
        }