13.07.2015 Views

Remoting in C# and .NET - The Journal of Object Technology

Remoting in C# and .NET - The Journal of Object Technology

Remoting in C# and .NET - The Journal of Object Technology

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

REMOTING IN <strong>C#</strong> AND .<strong>NET</strong>}thrd = new Thread(new ThreadStart(PollServer));thrd.Start();}}private void logoutBtn_Click(object sender, System.EventArgs e) {server.RemoveClient(this.name);listBox.Items.Clear();listBox.Items.Add("No longer logged <strong>in</strong>.");thrd.Abort();}private void PollServer() {for (; ; ) {Thread.Sleep(1000);ArrayList clients = server.Clients();listBox.Items.Clear();foreach (Str<strong>in</strong>g clientName <strong>in</strong> clients) {listBox.Items.Add(clientName);}Str<strong>in</strong>g sessionText = server.ChatSession();sessionTextBox.Clear();sessionTextBox.Text = sessionText;}}private void clearTextBtn_Click(object sender,System.EventArgs e) {sendTextBox.Clear();}private void sendBtn_Click(object sender, System.EventArgs e) {Str<strong>in</strong>g toSend = name + ": ";server.AddText(name + ":\n" + sendTextBox.Text + "\n\n");}us<strong>in</strong>g System;us<strong>in</strong>g System.Runtime.<strong>Remot<strong>in</strong>g</strong>;us<strong>in</strong>g System.Runtime.<strong>Remot<strong>in</strong>g</strong>.Channels;us<strong>in</strong>g System.Runtime.<strong>Remot<strong>in</strong>g</strong>.Channels.Http;namespace <strong>Remot<strong>in</strong>g</strong> {public class StartServer {static void Ma<strong>in</strong>() {// Create <strong>and</strong> register the channelHttpChannel channel = new HttpChannel(12345);ChannelServices.RegisterChannel(channel);Console.WriteL<strong>in</strong>e("Start<strong>in</strong>g ChatServer");// Register the ChatServer for remot<strong>in</strong>gVOL. 3, NO. 1 JOURNAL OF OBJECT TECHNOLOGY 99

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!