wpfxml-rpcsimplexmlrpcserverxml-rpc.net

How to display XML-RPC.Net Server instance data in the UI?


We've trying recently to use XML-RPC.Net library on our project. Both server(.Net Remoting) and client have been made according to the instructions we've found on http://xml-rpc.net/.

The connection has been made, we obtain data from the server and so on.

As the title states, now, we'd like to know how to make our XML-RPC server instance, which is created after the first client call, be able to give feedback to a WPF UI. What we'd like to accomplish is to register an event on a server property so the call could arrive to the UI thread.

We are open to any suggestions in this regard.

Here is the code that registers the channel on server side:

IDictionary props = new Hashtable();
props["name"] = "SubsetHttpChannel";
props["port"] = 5678;
channel = new System.Runtime.Remoting.Channels.Http.HttpChannel(
           props,
           null,
           new XmlRpcServerFormatterSinkProvider()
        );
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType( typeof(SubsetServer), "subsetserver.rem", WellKnownObjectMode.Singleton);

This is the code that shows how we'd like to set the property after Server instance is created on the UI:

Server = new SubsetServer(); 
Server.Machine.OnChangeState += delegate(State actual, State next, Event pEvent)
        {
            uiWindowInstance.PostMessage(string.Format("Subset Server: {0} -> {1}", actual.Name, next.Name));
};

Technologies used: VS2012, WPF 4.5 and XML-RPC.NET 2.5.0

Thanks in Advance


Solution

  • Thanks to anyone that took the time to read it and try to answer.

    I found a solution that fits me for the moment. I'd like to share it with you in the hope someone could give any hints wheter this is a solution that may generate problems in the future.

    After analyzing, I found out that both server instances run in the same process. So I've created a Singleton as a property inside my Server.

    I've put whatever I need inside the Singleton, so for the delegate I'd like to use in my question, the code now is:

    Server = new SubsetServer();
    Server.**singleton**.Machine.OnChangeState += delegate(State actual, State next, Event pEvent)
            {
                uiWindowInstance.PostMessage(string.Format("Subset Server: {0} -> {1}", actual.Name, next.Name));
            };
    

    Hope this helps anyone else. Please comment if you find any flaws.