Skip to content

Commit

Permalink
added possibility to configure streamed binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Zorn committed Nov 29, 2011
1 parent 7607fde commit 3df8b21
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
Expand Up @@ -33,14 +33,22 @@ public class GraphDS_RemoteClient : IGraphDSClient, ITransactionable, IServiceTo
private StreamedService _StreamedService;
private SecurityToken _SecurityToken;
private Int64 _TransactionToken;

public Boolean UseStreaming { get; private set; }

#endregion


#region Constructor

public GraphDS_RemoteClient(Uri myServiceAddress, bool myIsSecure = false)
public GraphDS_RemoteClient(Uri myServiceAddress, bool myIsSecure = false, bool myUseStreaming = false)
{
#if __MonoCS__
UseStreaming = false;
#else
UseStreaming = myUseStreaming;
#endif

BasicHttpBinding BasicBinding = new BasicHttpBinding();
BasicBinding.Name = "sonesBasic";
BasicBinding.MessageEncoding = WSMessageEncoding.Text;
Expand All @@ -62,10 +70,13 @@ public GraphDS_RemoteClient(Uri myServiceAddress, bool myIsSecure = false)
StreamedBinding.Name = "sonesStreamed";
StreamedBinding.MessageEncoding = WSMessageEncoding.Text;
StreamedBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
StreamedBinding.TransferMode = TransferMode.Streamed;
StreamedBinding.MaxReceivedMessageSize = 2147483648;
StreamedBinding.MaxBufferSize = 4096;
StreamedBinding.MaxReceivedMessageSize = 2147483647;
StreamedBinding.MaxBufferSize = (UseStreaming == true) ? 4096 : 2147483647;
StreamedBinding.SendTimeout = new TimeSpan(1, 0, 0, 0);
if (UseStreaming == true)
{
StreamedBinding.TransferMode = TransferMode.Streamed;
}

if (myIsSecure == true)
{
Expand Down
Expand Up @@ -82,8 +82,12 @@ public void Start(IDictionary<string, object> myStartParameter = null)
if (myStartParameter != null && myStartParameter.ContainsKey("Port"))
Port = (ushort)Convert.ChangeType(myStartParameter["Port"], typeof(ushort));

bool UseStreaming = false;
if (myStartParameter != null && myStartParameter.ContainsKey("UseStreaming"))
UseStreaming = (bool)Convert.ChangeType(myStartParameter["UseStreaming"], typeof(bool));

_RunningTime.Start();
_RPCServer = new sonesRPCServer(_GraphDS, Address, Port, UriPattern, _IsSecure);
_RPCServer = new sonesRPCServer(_GraphDS, Address, Port, UriPattern, _IsSecure, UseStreaming);
_RPCServer.StartServiceHost();
_description = " * RemoteAPI Service is started at " + _RPCServer.URI + Environment.NewLine +
" * web service definition can be found at " + Environment.NewLine +
Expand Down
Expand Up @@ -63,6 +63,11 @@ public class sonesRPCServer
/// Indicates wether the Server uses SSL
/// </summary>
public Boolean IsSecure { get; private set; }

/// <summary>
/// Indicates wether the Server provides the streamed binding
/// </summary>
public Boolean UseStreaming { get; private set; }

/// <summary>
/// Indicates wether the Server is running
Expand Down Expand Up @@ -104,8 +109,14 @@ public class sonesRPCServer

#region C'tor

public sonesRPCServer(IGraphDS myGraphDS, IPAddress myIPAdress, ushort myPort, String myURI, Boolean myIsSecure, Boolean myAutoStart = false, Boolean myIsSingleFile = false)
public sonesRPCServer(IGraphDS myGraphDS, IPAddress myIPAdress, ushort myPort, String myURI, Boolean myIsSecure, Boolean myUseStreaming = false, Boolean myAutoStart = false, Boolean myIsSingleFile = false)
{

#if __MonoCS__
this.UseStreaming = false;
#else
this.UseStreaming = myUseStreaming;
#endif
this._GraphDS = myGraphDS;
this.IsSecure = myIsSecure;
this.ListeningIPAdress = myIPAdress;
Expand All @@ -114,6 +125,8 @@ public sonesRPCServer(IGraphDS myGraphDS, IPAddress myIPAdress, ushort myPort, S
this.URI = new Uri((myIsSecure == true ? "https://" : "http://") + myIPAdress.ToString() + ":" + myPort + "/" + myURI);
this.MexUri = new Uri("http://" + myIPAdress.ToString() + ":" + (myPort + 1) + "/" + myURI);



if (!this.URI.IsWellFormedOriginalString())
throw new Exception("The URI Pattern is not well formed!");

Expand Down Expand Up @@ -148,27 +161,29 @@ private void InitializeServer()
readerQuotas.MaxArrayLength = 2147483647;
BasicBinding.ReaderQuotas = readerQuotas;


BasicHttpBinding StreamedBinding = new BasicHttpBinding();
StreamedBinding.Name = "sonesStreamed";
StreamedBinding.Namespace = Namespace;
StreamedBinding.MessageEncoding = WSMessageEncoding.Text;
StreamedBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
StreamedBinding.TransferMode = TransferMode.Streamed;
StreamedBinding.MaxReceivedMessageSize = 2147483648;
StreamedBinding.MaxBufferSize = 4096;
StreamedBinding.MaxReceivedMessageSize = 2147483647;
StreamedBinding.MaxBufferSize = (UseStreaming == true) ? 4096 : 2147483647;
StreamedBinding.SendTimeout = new TimeSpan(1, 0, 0, 0);
StreamedBinding.ReceiveTimeout = new TimeSpan(1, 0, 0, 0);
if (UseStreaming == true)
{
StreamedBinding.TransferMode = TransferMode.Streamed;
}

WebHttpBinding WebBinding = new WebHttpBinding();
WebBinding.Name = "sonesWeb";
WebBinding.Namespace = Namespace;
WebBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;



if (IsSecure)
{
BasicBinding.Security.Mode = BasicHttpSecurityMode.Transport;
BasicBinding.Security.Mode = BasicHttpSecurityMode.Transport;
StreamedBinding.Security.Mode = BasicHttpSecurityMode.Transport;
}

Expand Down

0 comments on commit 3df8b21

Please sign in to comment.