private void buttonLogIn_Click(object sender, EventArgs e) { if (this.service != null) { this.service.Provider.Disconnect(); this.service = null; } INodeEndpointProtocolFactory factory = new NamedPipeProtocolFactory(); this.service = factory.WaitForClient <ICommunicationService, CommunicationCallback>( textBoxServerName.Text, "CommunicaitonService", new CommunicationCallback(this, textBoxDisplayName.Text) ); if (this.service == null) { this.buttonChange.Enabled = false; this.buttonSend.Enabled = false; MessageBox.Show("Log in failed.", this.Text); } else { this.buttonChange.Enabled = true; this.buttonSend.Enabled = true; } }
static void Main(string[] args) { INodeEndpointProtocolFactory factory = new NamedPipeProtocolFactory(); INodeEndpointProtocolServerListener listener = factory.CreateServerListener(); Thread serverThread = new Thread(() => { while (true) { CommunicationService service = new CommunicationService(); INodeEndpointProtocolServer server = listener.WaitForServer("VczhCommunication", service); lock (loggedInServices) { loggedInServices.Add(Tuple.Create(server, service)); } SendMessageToAll("Someone logged in"); } }); serverThread.Start(); Console.WriteLine("Press [ENTER] to exit."); Console.Read(); serverThread.Abort(); }
static void Main(string[] args) { INodeEndpointProtocolFactory protocolFactory = new NamedPipeProtocolFactory(); ICalculationService client = protocolFactory.WaitForClient <ICalculationService>("localhost/GuardedServiceTest", "CalculationService"); Console.WriteLine("ICalculationService.Add(1, 2) == " + client.Add(1, 2).ToString()); client.Dispose(); Console.ReadLine(); }
public TcpShareProviderServiceRedirector(int port, NamedPipeProtocolFactory protocolFactory, INodeEndpointProtocolServer server) { this.protocolFactory = protocolFactory; this.server = server; this.port = port; }