コード例 #1
0
        private void Connect()
        {
            if (proxy == null)
            {
                try
                {
                    this.localClient      = new VersInformerServiceRef.Client();
                    this.localClient.Name = txtUserName.Text.ToString();

                    InstanceContext context = new InstanceContext(this);
                    proxy = new VersInformerServiceRef.VersInformerClient(context);


                    string servicePath       = proxy.Endpoint.ListenUri.AbsolutePath;
                    string serviceListenPort = proxy.Endpoint.Address.Uri.Port.ToString();

                    proxy.Endpoint.Address =
                        new EndpointAddress("net.tcp://" + txtIp.Text.ToString() + ":" + serviceListenPort + servicePath);


                    proxy.Open();

                    proxy.InnerDuplexChannel.Faulted += new EventHandler(InnerDuplexChannel_Faulted);
                    proxy.InnerDuplexChannel.Opened  += new EventHandler(InnerDuplexChannel_Opened);
                    proxy.InnerDuplexChannel.Closed  += new EventHandler(InnerDuplexChannel_Closed);
                    proxy.ConnectAsync(this.localClient);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    ToggleConnectServerButton(proxy.State == CommunicationState.Opened);
                    ToggleConnectionStateLabel(proxy.State == CommunicationState.Opened);
                    ToggleConnectedControls(proxy.State == CommunicationState.Opened);
                    ToggleDisconnectedControls(proxy.State == CommunicationState.Opened);
                }
            }
        }
コード例 #2
0
 public void UserLeave(VersInformerServiceRef.Client client)
 {
     MessageBox.Show("Kullanıcı gitti : " + client.Name);
 }
コード例 #3
0
 public void UserJoin(VersInformerServiceRef.Client client)
 {
     MessageBox.Show("Kullanıcı geldi : " + client.Name);
 }