Free cookie consent management tool by TermsFeed Policy Generator

source: branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs @ 13918

Last change on this file since 13918 was 13918, checked in by thasling, 8 years ago

#2615: implemented Dispose()-Method in all classes
also sending a message with the wcf-sender class was rewritten, because of Dispose
added new log entries when server removes peers from its dicionary

File size: 1.0 KB
Line 
1using System;
2using System.ServiceModel;
3using DistributedGA.Core.Domain;
4using DistributedGA.Core.Interface;
5
6namespace DistributedGA.Core.Implementation {
7  public class WcfMessageSender : IMessageSender {
8    private PeerInfo myself;
9
10    public void Init(PeerInfo source) {
11      myself = source;
12    }
13
14    public void SendData(PeerInfo destination, byte[][] data) {
15
16      var serviceUrl = "DistributedGA.svc";
17      var baseUri = new Uri(string.Concat("net.tcp://", destination.IpAddress, ":", destination.Port, "/DistributedGA"));
18      var serviceUri = new Uri(baseUri, serviceUrl);
19
20      var binding = new NetTcpBinding();
21      var endpoint = new EndpointAddress(serviceUri);
22      using (var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint)) {
23        using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) {
24          ((IMessageContract)client).SendData(myself, data); //maybe timout exception...
25        }
26      }
27    }
28
29    public void Dispose() {
30
31    }
32  }
33}
Note: See TracBrowser for help on using the repository browser.