diff --git a/GBase.Client/GBase.Client.csproj b/GBase.Client/GBase.Client.csproj
index 30fe1b7..fe4029e 100644
--- a/GBase.Client/GBase.Client.csproj
+++ b/GBase.Client/GBase.Client.csproj
@@ -28,6 +28,7 @@
+
diff --git a/GBase.Client/Services/Service.cs b/GBase.Client/Services/Service.cs
index a58b949..a4cf456 100644
--- a/GBase.Client/Services/Service.cs
+++ b/GBase.Client/Services/Service.cs
@@ -5,23 +5,30 @@
using System;
using System.ServiceModel;
using System.Threading.Tasks;
+using GBase.Api.Communication;
namespace GBase.Client.Services
{
public abstract class Service : IAsyncDisposable
{
- protected Service(string endpoint)
+ protected Service(ServerProtocol serverProtocol, string endpoint)
{
- ServiceFactory = OpenFactory(endpoint);
+ ServiceFactory = OpenFactory(serverProtocol, endpoint);
}
private ChannelFactory ServiceFactory { get; }
- private ChannelFactory OpenFactory(string endpoint)
+ private ChannelFactory OpenFactory(ServerProtocol serverProtocol, string endpoint)
{
- ChannelFactory factory = new ChannelFactory(new BasicHttpBinding(), new EndpointAddress(endpoint));
- factory.Open();
+ ChannelFactory factory;
+ if (serverProtocol == ServerProtocol.Http)
+ factory = new ChannelFactory(new BasicHttpBinding(), new EndpointAddress(endpoint));
+ else if (serverProtocol == ServerProtocol.Tcp)
+ factory = new ChannelFactory(new NetTcpBinding(), new EndpointAddress(endpoint)); //TODO: Set security mode here?
+ else
+ throw new ArgumentOutOfRangeException(nameof(serverProtocol), serverProtocol, "Invalid server protocol used.");
+ factory.Open();
return factory;
}