Last change
on this file since 13524 was
13524,
checked in by thasling, 8 years ago
|
Upload des Projekts letztendlich, trotz buggendes Clients...
|
File size:
1.4 KB
|
Line | |
---|
1 | using DistributedGA.Core.Domain;
|
---|
2 | using DistributedGA.Core.Interface;
|
---|
3 | using System;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using System.Linq;
|
---|
6 | using System.ServiceModel;
|
---|
7 | using System.Text;
|
---|
8 | using System.Threading.Tasks;
|
---|
9 |
|
---|
10 | namespace DistributedGA.Core.Implementation
|
---|
11 | {
|
---|
12 | public class WcfMessageSender : IMessageSender
|
---|
13 | {
|
---|
14 | private PeerInfo myself;
|
---|
15 |
|
---|
16 | public void Init(PeerInfo source)
|
---|
17 | {
|
---|
18 | myself = source;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public void SendPopulation(PeerInfo destination, SolutionInfo[] population)
|
---|
22 | {
|
---|
23 | var client = CreateServerClient(destination.IpAddress, destination.Port);
|
---|
24 | client.SendPopulation(myself, population); //maybe timout exception...
|
---|
25 | }
|
---|
26 |
|
---|
27 | private IMessageContract CreateServerClient(string ip, int port)
|
---|
28 | {
|
---|
29 | var serviceUrl = "DistributedGA.svc";
|
---|
30 | var baseUri = new Uri(string.Concat("http://", ip, ":", port, "/DistributedGA"));
|
---|
31 | var serviceUri = new Uri(baseUri, serviceUrl);
|
---|
32 |
|
---|
33 | var binding = new BasicHttpBinding();
|
---|
34 | var endpoint = new EndpointAddress(serviceUri);
|
---|
35 | var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint);
|
---|
36 |
|
---|
37 | IMessageContract client = null;
|
---|
38 | client = myChannelFactory.CreateChannel();
|
---|
39 | return client;
|
---|
40 | }
|
---|
41 |
|
---|
42 | }
|
---|
43 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.