Skip to content

Commit

Permalink
Updating ZDevices: ZContext.Current
Browse files Browse the repository at this point in the history
  • Loading branch information
metadings committed Sep 17, 2015
1 parent ee1dc23 commit bd70615
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
14 changes: 13 additions & 1 deletion Devices/PubSubDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class PubSubDevice : ZDevice
/// </summary>
public static readonly ZSocketType BackendType = ZSocketType.XPUB;

/// <summary>
/// Initializes a new instance of the <see cref="PubSubDevice"/> class.
/// </summary>
public PubSubDevice() : this(ZContext.Current) { }

/// <summary>
/// Initializes a new instance of the <see cref="PubSubDevice"/> class.
/// </summary>
Expand All @@ -27,7 +32,14 @@ public PubSubDevice(ZContext context)
}

/// <summary>
/// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
/// Initializes a new instance of the <see cref="PubSubDevice"/> class.
/// </summary>
public PubSubDevice(string frontendBindAddr, string backendBindAddr)
: this(ZContext.Current, frontendBindAddr, backendBindAddr)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="PubSubDevice"/> class.
/// </summary>
public PubSubDevice(ZContext context, string frontendBindAddr, string backendBindAddr)
: base(context, FrontendType, BackendType)
Expand Down
18 changes: 15 additions & 3 deletions Devices/PushPullDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ public class PushPullDevice : ZDevice
/// The backend <see cref="ZSocketType"/> for a streamer device.
/// </summary>
public static readonly ZSocketType BackendType = ZSocketType.PUSH;


/// <summary>
/// Initializes a new instance of the <see cref="PushPullDevice"/> class.
/// </summary>
public PushPullDevice() : this(ZContext.Current) { }

/// <summary>
/// Initializes a new instance of the <see cref="PushPullDevice"/> class.
/// </summary>
Expand All @@ -25,7 +30,14 @@ public PushPullDevice(ZContext context)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="StreamerDevice"/> class.
/// Initializes a new instance of the <see cref="PushPullDevice"/> class.
/// </summary>
public PushPullDevice(string frontendBindAddr, string backendBindAddr)
: this(ZContext.Current, frontendBindAddr, backendBindAddr)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="PushPullDevice"/> class.
/// </summary>
public PushPullDevice(ZContext context, string frontendBindAddr, string backendBindAddr)
: base(context, FrontendType, BackendType)
Expand All @@ -43,7 +55,7 @@ protected override bool FrontendHandler(ZSocket args, out ZMessage message, out
}

/// <summary>
/// Not implemented for the <see cref="StreamerDevice"/>.
/// Not implemented for the <see cref="PushPullDevice"/>.
/// </summary>
protected override bool BackendHandler(ZSocket args, out ZMessage message, out ZError error)
{
Expand Down
13 changes: 13 additions & 0 deletions Devices/RouterDealerDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@ public class RouterDealerDevice : ZDevice
/// The backend <see cref="ZSocketType"/> for a queue device.
/// </summary>
public static readonly ZSocketType BackendType = ZSocketType.DEALER;

/// <summary>
/// Initializes a new instance of the <see cref="RouterDealerDevice"/> class.
/// </summary>
public RouterDealerDevice() : this(ZContext.Current) { }

/// <summary>
/// Initializes a new instance of the <see cref="RouterDealerDevice"/> class.
/// </summary>
public RouterDealerDevice(ZContext context)
: base(context, FrontendType, BackendType)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="RouterDealerDevice"/> class
/// and binds to the specified Frontend and Backend address.
/// </summary>
public RouterDealerDevice(string frontendBindAddr, string backendBindAddr)
: this(ZContext.Current, frontendBindAddr, backendBindAddr)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="RouterDealerDevice"/> class
Expand Down
11 changes: 11 additions & 0 deletions Devices/StreamDealerDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,23 @@ public class StreamDealerDevice : ZDevice
/// </summary>
public static readonly ZSocketType BackendType = ZSocketType.DEALER;

/// <summary>
/// Initializes a new instance of the <see cref="StreamDealerDevice"/> class.
/// </summary>
public StreamDealerDevice() : this(ZContext.Current) { }
/// <summary>
/// Initializes a new instance of the <see cref="StreamDealerDevice"/> class.
/// </summary>
public StreamDealerDevice(ZContext context)
: base(context, FrontendType, BackendType)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="StreamDealerDevice"/> class.
/// </summary>
public StreamDealerDevice(string frontendBindAddr, string backendBindAddr)
: this(ZContext.Current, frontendBindAddr, backendBindAddr)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="StreamDealerDevice"/> class.
Expand Down
18 changes: 18 additions & 0 deletions ZDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,30 @@ public abstract class ZDevice : ZThread
/// </summary>
public ZSocket BackendSocket;

protected ZDevice()
: this (ZContext.Current)
{ }

protected ZDevice(ZContext context)
: base()
{
Context = context;
}

/// <summary>
/// Initializes a new instance of the <see cref="ZDevice"/> class.
/// </summary>
/// <param name="frontendSocket">
/// A <see cref="ZSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
/// </param>
/// <param name="backendSocket">
/// A <see cref="ZSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
/// </param>
/// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
protected ZDevice(ZSocketType frontendType, ZSocketType backendType)
: this (ZContext.Current, frontendType, backendType)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="ZDevice"/> class.
/// </summary>
Expand Down

0 comments on commit bd70615

Please sign in to comment.