Skip to content

Commit

Permalink
Cleaning up NotificationService constructors to reuse/reduce code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Moak committed Sep 8, 2011
1 parent 5dc55bd commit ef8674c
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions JdSoft.Apple.Apns.Notifications/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

namespace JdSoft.Apple.Apns.Notifications
{
public class NotificationService : IDisposable
using System.IO;

public class NotificationService : IDisposable
{
#region Constants
private const string hostSandbox = "gateway.sandbox.push.apple.com";
private const string hostProduction = "gateway.push.apple.com";
private const int apnsPort = 2195;
#endregion

#region Delegates and Events
Expand Down Expand Up @@ -111,6 +114,7 @@ public class NotificationService : IDisposable
#endregion

#region Constructors

/// <summary>
/// Constructor
/// </summary>
Expand All @@ -119,16 +123,8 @@ public class NotificationService : IDisposable
/// <param name="p12File">PKCS12 .p12 or .pfx File containing Public and Private Keys</param>
/// <param name="connections">Number of Apns Connections to start with</param>
public NotificationService(string host, int port, string p12File, int connections)
: this(host, port, p12File, null, connections)
{
this.SendRetries = 1;
closing = false;
disposing = false;
Host = host;
Port = port;
P12File = p12File;
P12FilePassword = null;
DistributionType = NotificationServiceDistributionType.Sequential;
Connections = connections;
}

/// <summary>
Expand Down Expand Up @@ -159,16 +155,8 @@ public NotificationService(string host, int port, string p12File, string p12File
/// <param name="p12File">PKCS12 .p12 or .pfx File containing Public and Private Keys</param>
/// <param name="connections">Number of Apns Connections to start with</param>
public NotificationService(bool sandbox, string p12File, int connections)
: this(sandbox ? hostSandbox : hostProduction, apnsPort, p12File, null, connections)
{
this.SendRetries = 1;
closing = false;
disposing = false;
Host = sandbox ? hostSandbox : hostProduction;
Port = 2195;
P12File = p12File;
P12FilePassword = null;
DistributionType = NotificationServiceDistributionType.Sequential;
Connections = connections;
}

/// <summary>
Expand All @@ -178,18 +166,12 @@ public NotificationService(bool sandbox, string p12File, int connections)
/// <param name="p12File">PKCS12 .p12 or .pfx File containing Public and Private Keys</param>
/// <param name="p12FilePassword">Password protecting the p12File</param>
/// <param name="connections">Number of Apns Connections to start with</param>
public NotificationService(bool sandbox, string p12File, string p12FilePassword, int connections)
{
this.SendRetries = 1;
closing = false;
disposing = false;
Host = sandbox ? hostSandbox : hostProduction;
Port = 2195;
P12File = p12File;
P12FilePassword = p12FilePassword;
DistributionType = NotificationServiceDistributionType.Sequential;
Connections = connections;
}
public NotificationService(bool sandbox, string p12File, string p12FilePassword, int connections) :
this(sandbox ? hostSandbox : hostProduction, apnsPort, p12File, p12FilePassword, connections)
{

}

#endregion

#region Properties
Expand Down

0 comments on commit ef8674c

Please sign in to comment.