IListenWaitConnector Interface
Represents a IReceivingConnector connector that is persistant in memory and can "listen" for data over a transport channel

Namespace: MARC.Everest.Connectors
Assembly: MARC.Everest.Phone (in MARC.Everest.Phone.dll) Version: 1.5.0.0 (1.5.0)

Syntax

C#

public interface IListenWaitConnector : IReceivingConnector, 
	IConnector, IDisposable

Examples

Running an IListenWaitConnector in synchronous mode

 // Setup the formatter
XmlIts1Formatter fmtr = new XmlIts1Formatter();
fmtr.GraphAides.Add(new DatatypeFormatter() 
{ 
    ValidateConformance = false 
});
fmtr.ValidateConformance = false;

 // Prepare the connection string
FileConnectionStringBuilder fsb = new FileConnectionStringBuilder()
{
    Directory = "C:\\temp",
    Pattern = "*.xml"
};

 // Create the connector
IListenWaitConnector connector = new FileListenConnector(fsb.GenerateConnectionString());
 // Set the formatter
((IFormattedConnector)connector).Formatter = fmtr;

try
{
    // Open the channel and start accepting messages
    connector.Open();
    connector.Start();

    // Wait until a message is available
    IReceiveResult result = connector.Receive();

    // Output the type
    Console.WriteLine(result.Structure.ToString());
}
finally
{
    connector.Close();
    connector.Dispose();
}

Running an IListenWaitConnector in Asynchronous mode

static void Main(string[] args)
{

    // Good practice to force load
    Assembly.Load(new AssemblyName("MARC.Everest.RMIM.UV.NE2008"));

    // Setup the formatter
    XmlIts1Formatter fmtr = new XmlIts1Formatter();

    // Formatter & Connector Connection String Truncated to save space 

    // Create the connector
    IListenWaitConnector connector = new FileListenConnector(fsb.GenerateConnectionString());

    // Set the formatter
    ((IFormattedConnector)connector).Formatter = fmtr;

    try
    {
        // Open the channel and start accepting messages
        connector.Open();

        // Set the event handler
        connector.MessageAvailable += new 
               EventHandler<UnsolicitedDataEventArgs>(
                   connector_MessageAvailable
               );

        // Start listening
        connector.Start();

        Console.WriteLine("Drop a message in the directory!");
        Console.WriteLine("Press any key to stop listening");
        Console.ReadKey();
    }
    finally
    {
        connector.Close();
        connector.Dispose();
    }
}

 /// <summary> 
 /// Process the message 
 /// </summary> 
static void connector_MessageAvailable(object sender, UnsolicitedDataEventArgs e)
{
    // Receive the result message
    IReceiveResult result = (sender as IListenWaitConnector).Receive();
    Console.WriteLine(result.Structure.ToString());
}

Version Information

Everest Compact Framework

Supported in: 1.2 Compact

Everest Framework

Supported in: 1.2, 1.0

See Also