示例#1
0
        private void Login()
        {
            try
            {
                Window1 LoginWin = new Window1();
                LoginWin.ShowDialog();
                username = LoginWin.GetName();

                //InstanceContext ins = new InstanceContext(this);
                //proxy = new QQProxy(ins);

                //IAsyncResult iar = proxy.BeginJoin(username, new AsyncCallback(OnEndJoin), null);

                AnnouncementService announcementService = new AnnouncementService();
                announcementService.OnlineAnnouncementReceived += (sender, e) =>
                    {
                        string contractTypes = string.Empty;
                        ShowTextBox.AppendText("Receive Service Online Announcement.");
                        ShowTextBox.AppendText(string.Format("\tAddress: {0}", e.EndpointDiscoveryMetadata.Address.Uri));
                        ShowTextBox.AppendText(string.Format("\tContract: {0}", e.EndpointDiscoveryMetadata.ContractTypeNames[0]));
                    };

                announcementService.OfflineAnnouncementReceived += (sender, e) =>
                    {
                        string contractTypes = string.Empty;
                        ShowTextBox.AppendText("Receive Service Offline Announcement.");
                        ShowTextBox.AppendText(string.Format("\tAddress: {0}", e.EndpointDiscoveryMetadata.Address.Uri));
                        ShowTextBox.AppendText(string.Format("\tContract: {0}", e.EndpointDiscoveryMetadata.ContractTypeNames[0]));
                    };

                using (ServiceHost host = new ServiceHost(announcementService))
                {
                    host.Open();
                    Console.Read();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#2
0
        private void Login()
        {
            try
            {
                Window1 LoginWin = new Window1();
                LoginWin.ShowDialog();
                username = LoginWin.GetName();

                InstanceContext ins = new InstanceContext(this);
                proxy = new QQProxy(ins);

                IAsyncResult iar = proxy.BeginJoin(username, new AsyncCallback(OnEndJoin), null);
            }
            catch (Exception e)
            {
                throw e;
            }
        }