Local Channel sample (.NET)

Overview

This sample demonstrates how to work with the single-tier version of the Remoting SDK server.

Getting Started

Build and launch the LocalChannel sample. Set the first and second variable and click the button Sum. The corresponding result will be shown.

Examine the code

The LocalChannel sample represents the single-tier version of the Remoting SDK server due to the LocalServerChannel and LocalClientChannel components:

  • The LocalServerChannel implements a server that makes services available for consumption from within the same executable via a LocalClientChannel.
  • The LocalClientChannel implements a channel that talks to Services in the same executable via a LocalServerChannel.

These channels are helpful when you create a single-tier version of an existing client/server application and want to combine client and server logic in the same executable to avoid the overhead of a "real" communication channel between client and server.

In the rest, the LocalChannel sample uses a standard proxy service object to work with the service:

private RemObjects.SDK.Server.LocalServerChannel localServerChannel;
private RemObjects.SDK.LocalClientChannel localClientChannel;
private RemObjects.SDK.BinMessage serverBinMessage;
private RemObjects.SDK.BinMessage clientBinMessage;

private void btn_Sum_Click(object sender, System.EventArgs e)
{
   INewService s = CoNewService.Create(clientBinMessage, localClientChannel);
   Int32 A, B;
   if (Int32.TryParse(ed_A.Text, out A) && Int32.TryParse(ed_B.Text, out B))
   {
       MessageBox.Show(s.Sum(A, B).ToString());
   }
   else
   {
     MessageBox.Show("Wrong data");
   }
}