Skip to content

Commit

Permalink
Added receiver IP to interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesper Hermansen committed Dec 27, 2018
1 parent a52c831 commit 7080fb7
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 41 deletions.
5 changes: 2 additions & 3 deletions Artnet Emu/Artnet Emu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<PublisherName>Jesper Hermansen</PublisherName>
<WebPage>publish.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>17</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down Expand Up @@ -246,7 +246,6 @@
<ItemGroup>
<Content Include="favicon.ico" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
12 changes: 7 additions & 5 deletions Artnet Emu/ArtnetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ public enum ArtnetServerState

public class ArtnetServer
{
private IPAddress Ip;
private IPAddress SenderIp;
private IPAddress ReceiverIp;
private int Port;
private bool StopRequested = false;
private byte[] UniverseSequences;
private static UdpClient Socket;
public ArtnetServer(IPAddress ip, int port)
public ArtnetServer(IPAddress sender, IPAddress receiver, int port)
{
Ip = ip;
SenderIp = sender;
ReceiverIp = receiver;
Port = port;
}

Expand Down Expand Up @@ -141,7 +143,7 @@ public void Terminate()
public void Run()
{
UniverseSequences = new byte[256*256];
IPEndPoint listenerIp = new IPEndPoint(IPAddress.Any, Port);
IPEndPoint listenerIp = new IPEndPoint(ReceiverIp, Port);
if (Socket != null)
{
Socket.Close();
Expand All @@ -157,7 +159,7 @@ public void Run()
OnThreadState(ArtnetServerState.Aborted);
return;
}
IPEndPoint senderIp = new IPEndPoint(Ip, 0);
IPEndPoint senderIp = new IPEndPoint(SenderIp, 0);
OnThreadState(ArtnetServerState.Running);
while (!StopRequested)
{
Expand Down
80 changes: 59 additions & 21 deletions Artnet Emu/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 26 additions & 6 deletions Artnet Emu/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ private void MainWindow_Load(object sender, EventArgs e)
Config = new ApplicationConfiguration();
}
listConfigurations.Items.Clear();
txtIP.Text = Config.Address;
txtSenderIP.Text = Config.SenderIP;
txtReceiverIP.Text = Config.ReceiverIP;
menuITunes.Enabled = false;

string version = ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : "debug";
Text += " v." + version;
Expand Down Expand Up @@ -110,20 +112,34 @@ private void menuWinamp_Click(object sender, EventArgs e)

private void btnStartListener_Click(object sender, EventArgs e)
{
if (txtIP.Text == "")
if (txtSenderIP.Text == "")
{
txtIP.Text = "127.0.0.1";
txtSenderIP.Text = "127.0.0.1";
}
IPAddress ip;
try
{
ip = IPAddress.Parse(txtIP.Text);
ip = IPAddress.Parse(txtSenderIP.Text);
}
catch (Exception exception)
{
ShowMessageBox(exception.Message);
return;
}
if (txtReceiverIP.Text == "")
{
txtReceiverIP.Text = "0.0.0.0";
}
try
{
ip = IPAddress.Parse(txtReceiverIP.Text);
}
catch (Exception exception)
{
ShowMessageBox(exception.Message);
return;
}

btnStartListener.Enabled = false;
Application.DoEvents();
if (Server == null)
Expand Down Expand Up @@ -158,7 +174,7 @@ private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)

private void StartServer()
{
Server = new ArtnetServer(IPAddress.Parse(txtIP.Text), Convert.ToInt32(ConfigurationManager.AppSettings["ArtnetPort"]));
Server = new ArtnetServer(IPAddress.Parse(txtSenderIP.Text), IPAddress.Parse(txtReceiverIP.Text), Convert.ToInt32(ConfigurationManager.AppSettings["ArtnetPort"]));
Server.ThreadState += Server_ThreadState;
try {
foreach (PlayerConfiguration config in Config.Items)
Expand Down Expand Up @@ -228,6 +244,7 @@ private void InvokePacketReceived(ArtNetPacket packet)
PacketSequence = !PacketSequence;
}
pictureStatus.Invalidate();
lblStatus.Text = "Receiving";
}
}

Expand All @@ -243,6 +260,7 @@ private void Server_ThreadState(ArtnetServerState state)
else
{
btnStartListener.Text = state == ArtnetServerState.Running ? "Stop listener" : "Start listener";
lblStatus.Text = Enum.GetName(typeof (ArtnetServerState), state);
btnStartListener.Enabled = true;
if (state != ArtnetServerState.Running)
{
Expand Down Expand Up @@ -286,13 +304,15 @@ private void MainWindow_FormClosed(object sender, FormClosedEventArgs e)
Server.Terminate();
Server = null;
}
Config.Address = txtIP.Text;
Config.SenderIP = txtSenderIP.Text;
Config.ReceiverIP = txtReceiverIP.Text;
Config.Save();
}

private void contextMenuListView_Opening(object sender, CancelEventArgs e)
{
bool visible = listConfigurations.SelectedItems.Count >= 1;
menuViewMissing.Visible = visible;
menuViewFilelist.Visible = visible;
menuViewDuplicates.Visible = visible;
menuEditConfiguration.Visible = visible;
Expand Down
5 changes: 2 additions & 3 deletions Artnet Emu/MainWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureStatus.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAtSURBVChThcfBCQAgDAAx9x+j03UM//FAyCfnzP755JNPPvnkk08++eSTf81euy3dodag3NAA
AAAASUVORK5CYII=
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAABGdBTUEAALGPC/xhBQAAAC1JREFUKFOF
x8EJACAMADH3H6PTdQz/8UDIJ+fM/vnkk08++eSTTz755JN/zV67Ld2h1qDc0AAAAABJRU5ErkJggg==
</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
6 changes: 4 additions & 2 deletions Artnet Emu/Model/ApplicationConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ namespace ArtnetEmu.Model
public class ApplicationConfiguration
{
public List<PlayerConfiguration> Items;
public string Address;
public string SenderIP;
public string ReceiverIP;

public ApplicationConfiguration()
{
Items = new List<PlayerConfiguration>();
Address = "127.0.0.1";
SenderIP = "127.0.0.1";
ReceiverIP = "0.0.0.0";
}
private static string GetConfigurationFilename()
{
Expand Down
2 changes: 1 addition & 1 deletion Artnet Emu/Model/Players/ITunesMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
/**
* Remove comments in this file, to add support for iTunes.
* Remove comments in this file, and add iTunesLib as reference, to add support for iTunes.
*/
//using iTunesLib;

Expand Down

0 comments on commit 7080fb7

Please sign in to comment.