What you've seen previously constitutes a full-featured transport channel. It supports every .NET Remoting functionality: synchronous calls, asynchronous calls, and event notification. In addition, client-activated objects can be used with this channel. To use it on the server side, you can register it by implementing a configuration file like this:
<configuration> <system.runtime.remoting> <application> <channels> <channel name="smtp" type="SMTPChannel.SMTPChannel, SMTPChannel" senderEmail="server_1@localhost" smtpServer="localhost" pop3Server="localhost" pop3User="server_1" pop3Password="server_1" pop3PollInterval="1" isServer="yes" /> </channels> <service> <wellknown mode="Singleton" type="Service.SomeSAO, Service" objectUri="SomeSAO.soap" /> </service> </application> </system.runtime.remoting> </configuration>
The corresponding client-side configuration file might look like this:
<configuration> <system.runtime.remoting> <application> <channels> <channel name="smtp" type="SMTPChannel.SMTPChannel, SMTPChannel" senderEmail="client_1@localhost" smtpServer="localhost" pop3Server="localhost" pop3User="client_1" pop3Password="client_1" pop3PollInterval="1" isServer="yes" /> </channels> <client> <wellknown type="Service.SomeSAO, Service" url="smtp:server_1@localhost/SomeSAO.soap" /> </client> <client url="smtp:server_2@localhost"> <activated type="Service.SomeCAO, Service" /> </client> </application> </system.runtime.remoting> </configuration>
In the source code download that accompanies this book online, you'll find not only the complete implementation of this channel, but also a test environment consisting of three projects (two servers and a client) that shows the following features using the SMTPChannel:
Asynchronous calls using a delegate
Raising and handling events
Passing references to CAOs between different applications
To run the samples on your machine, you'll need to have access to three e-mail accounts (two for the servers and one for the client) with SMTP and POP3. For testing purposes I therefore recommend that you download and install Mercury/32, a free e-mail server, to allow you to easily perform the configuration without having to bother any system administrators. You can get it from http://www.pmail.com.
Please create three user accounts in Mercury/32 after installing and running it (Configuration ﾀ Manage local users), each having the same password as the user name: client_1, server_1, and server_2. You can see the final state in Figure 10-1.
Figure 10-1: These user accounts are needed for these examples.
You also need to change to Mercury core configuration (Configuration ﾀ Mercury core module) to recognize the local domain. To do this, switch to the Local domains tab and enter localhost in the Local host or server and Internet name text boxes as shown in Figure 10-2.
Figure 10-2: Preparing the core modules