Skip to content

Commit

Permalink
feat: add ability to set http port
Browse files Browse the repository at this point in the history
  • Loading branch information
ngenovese11 committed Apr 18, 2023
1 parent 0ff798c commit 2d8a288
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions PanasonicCameraEpi/PanasonicCameraFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,35 @@

namespace PanasonicCameraEpi
{
public class PanasonicCameraFactory : EssentialsPluginDeviceFactory<PanasonicCamera>
{

public PanasonicCameraFactory()
public class PanasonicCameraFactory : EssentialsPluginDeviceFactory<PanasonicCamera>
{
public PanasonicCameraFactory()
{
MinimumEssentialsFrameworkVersion = "1.8.5";

TypeNames = new List<string> { "panasonicHttpCamera"};
TypeNames = new List<string> {"panasonicHttpCamera"};
}

public override EssentialsDevice BuildDevice(DeviceConfig config)
{
var cameraConfig = PanasonicCameraPropsConfig.FromDeviceConfig(config);
if (!cameraConfig.Control.Method.Equals("http", StringComparison.OrdinalIgnoreCase))
throw new NotSupportedException("No valid control method found");
public override EssentialsDevice BuildDevice(DeviceConfig config)
{
var cameraConfig = PanasonicCameraPropsConfig.FromDeviceConfig(config);
if (!cameraConfig.Control.Method.Equals("http", StringComparison.OrdinalIgnoreCase))
throw new NotSupportedException("No valid control method found");

var hostname = cameraConfig.Control.TcpSshProperties.Port == 80 ||
cameraConfig.Control.TcpSshProperties.Port == 0
? cameraConfig.Control.TcpSshProperties.Address
: cameraConfig.Control.TcpSshProperties.Address + ":" +
cameraConfig.Control.TcpSshProperties.Port;

var client = new GenericHttpClient(string.Format("{0}-httpClient", config.Key), config.Name,
cameraConfig.Control.TcpSshProperties.Address);
var client = new GenericHttpClient(
string.Format("{0}-httpClient", config.Key),
config.Name,
hostname);

DeviceManager.AddDevice(client);
DeviceManager.AddDevice(client);

return new PanasonicCamera(client, config);
}
}
return new PanasonicCamera(client, config);
}
}
}

0 comments on commit 2d8a288

Please sign in to comment.