Ben Axelrod [CoroWare]


I know that if a .NET application hosts a DSS node, it can send messages to the services running in it. But is it possible to send messages to a MSRS service if the application does not host the node


If not, is there an elegant work around

Thanks,

-Ben




Re: Microsoft Robotics - Decentralized Software Services (DSS) Messages to service without hosting

Paul Hounshell

There is. That's what I was asking about in http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2322878&SiteID=1

What worked for me was to have my Server service (which ran in DSSHost), a Client service (which hosted itself), and the application. I also had to have the Security Manager disabled, otherwise I got errors.

Basically, the application starts up the environment and then starts up a local instance of the Client service using DssEnvironment.CreateService(). Then the Client connects to the Server using a ServiceForwarder. When you bring your Server up for the first time, connect to the Server via your web browser, go into the Security Manager and disable the Authentication

This is pretty much the pattern in the various tutorials. You can see the tutorial for the hosting of the Client service at http://msdn2.microsoft.com/en-us/library/bb643218.aspx and the tutorial for connecting to a remote node at http://msdn2.microsoft.com/en-us/library/bb483059.aspx





Re: Microsoft Robotics - Decentralized Software Services (DSS) Messages to service without hosting

Ben Axelrod [CoroWare]

So if I may summarize your solution, you have 2 DSS nodes running. One is inside the .NET application, and the other is started normally with DssHost. Once the appropriate services are running on each node, then you just use the standard MSRS inter-node communication schemes to send messages between them. Is this an accurate summary If so, I was actually looking for another solution... Although this is one way to do it.





Re: Microsoft Robotics - Decentralized Software Services (DSS) Messages to service without hosting

Rob Sim -- Braintech

If Ben is voting for a lightweight client API for sending/receiving DSS requests without starting a dss node I'll second that vote. Currently, the best way I can think of for a third-party app to talk to a node is to use HTTP requests. Obviously, this requires a lot of duplication of effort to implement each request type in the HTTP handler.









Re: Microsoft Robotics - Decentralized Software Services (DSS) Messages to service without hosting

Paul Hounshell

That's a pretty good summary of what I was talking about, and how I implemented it on my first pass. After some refactoring and testing I've pared it down a bit, but I'm sure someone could take it a couple steps further.

Here's what I do in the .NET application now:

1.) Start the DSS Environment

2.) Start up a service which has a SubscriptionManager partner (this service is not actually used, I'm just not too sure how to start up the subscription code without it)

3.) Create a ServiceForwarder for your server

4.) Use forwarder like normal

Here's the process the way I did it. I had to sanitize the example, so there may be some minor typos.

Code Block

private void StartDss()
{
DssEnvironment.Initialize(51000, 51001);

Arbiter.Activate(DssEnvironment.TaskQueue, Arbiter.FromIteratorHandler(SetupDssConnections));
}

public IEnumerator<ITask> SetupDssConnections()
{
Console.WriteLine("Creating Local Junk Service ({0})", JunkWithSubscriber.Proxy.Contract.Identifier);

yield return Arbiter.Choice(
DssEnvironment.CreateService(JunkWithSubscriber.Proxy.Contract.Identifier),
delegate(CreateResponse success)
{
Console.WriteLine("Local Junk Created At: " + success.Service);
},
delegate(W3C.Soap.Fault failure)
{
Console.WriteLine("Error Creating Local Junk: " + failure.Reason[0].Value);
DssEnvironment.Shutdown();
}
);


Uri Address = new Uri(@"http://des102:50000/MyServer");

MyServer.Proxy.MyServerOperations SubscriptionInboundPort = DssEnvironment.ServiceForwarder<MyServer.Proxy.MyServerOperations>(Address);

// Get operation

PortSet<MyServer.Proxy.UpdateData, W3C.Soap.Fault> GetResponses = new PortSet<MyServer.Proxy.UpdateData, W3C.Soap.Fault>();
MyServerOperations.Post(new MyServer.Proxy.Get(GetResponses));

yield return Arbiter.Choice(
GetResponses,
delegate(MyServer.Proxy.UpdateData response)
{
// Handle Retrieved Data
},
delegate(W3C.Soap.Fault failure)
{
Console.WriteLine("Error Getting Remote Data: " + failure.Reason[0].Value);
}
);


// Start up subscription

Port<MyServer.Proxy.SubscriptionUpdate> SubscriptionPort = new Port<MyServer.Proxy.SubscriptionUpdate>();
Port<MyServer.Proxy.SubscriptionUpdate> NewInboundPort = new Port<MyServer.Proxy.SubscriptionUpdate>();
Port<Shutdown> NewShutdownPort = new Port<Shutdown>();

MyServer.Proxy.Subscribe SubscribeRequest = new MyServer.Proxy.Subscribe
{
NotificationPort = NewInboundPort,
NotificationShutdownPort = NewShutdownPort
};

yield return Arbiter.Choice(
SubscriptionInboundPort.Subscribe(
new MyServer.Proxy.SubscribeRequestType(),
SubscriptionPort),
delegate(SubscribeResponseType response)
{
Console.WriteLine("Subscribed to Remote Data: " + response.SubscriptionManager);
},
delegate(W3C.Soap.Fault failure)
{
Console.WriteLine("Error Subscribing to Remote Data: " + failure.Reason[0].Value);
}
);

Arbiter.Activate(
DssEnvironment.TaskQueue,
Arbiter.Receive(
true,
SubscriptionPort,
delegate(MyServer.Proxy.Update update)
{
// Handle Inbound Subscription message
}
));
}





Re: Microsoft Robotics - Decentralized Software Services (DSS) Messages to service without hosting

Ben Axelrod [CoroWare]

Rob is on the right track. Anyone have ideas






Re: Microsoft Robotics - Decentralized Software Services (DSS) Messages to service without hosting

George Chrysanthakopoulos

Ben, DssEnvironment is currently what we recommend. Its a one liner and you can call it from your own EXE. That is what you should be using for sending messages to other Dss services, from an arbitrary executable.

thanx

g