Add BeacomMessage property to pixelhub server for debugging purposes & send debugging message
This commit is contained in:
parent
98daa35b46
commit
e961c558ac
3 changed files with 12 additions and 4 deletions
|
@ -87,6 +87,12 @@ namespace PixelHub.Net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string BeaconMessage {
|
||||||
|
get {
|
||||||
|
return $"{Role}@{LocalIP}:{Port}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PixelHub.Net.DiscoveryBeacon"/> class.
|
/// Initializes a new instance of the <see cref="PixelHub.Net.DiscoveryBeacon"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -172,7 +178,7 @@ namespace PixelHub.Net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task emitOnce()
|
private async Task emitOnce()
|
||||||
{
|
{
|
||||||
await Send($"{Role}@{LocalIP}:{Port}");
|
await Send(BeaconMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace PixelHub.Server
|
||||||
StreamWriter outgoing;
|
StreamWriter outgoing;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new <see cref="PixelHub.Server.PixelBot"/> instance and connects it to a Hull Pixelbot.
|
/// Initializes a new <see cref="PixelBot"/> instance and connects it to a Hull Pixelbot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inClient">The Tcp connection between the PixelHub server and the Hull PixelBot.</param>
|
/// <param name="inClient">The Tcp connection between the PixelHub server and the Hull PixelBot.</param>
|
||||||
public PixelBot(TcpClient inClient)
|
public PixelBot(TcpClient inClient)
|
||||||
|
@ -28,7 +28,6 @@ namespace PixelHub.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts listening for and handling messages that come from the remote PixelBot.
|
/// Starts listening for and handling messages that come from the remote PixelBot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="client">Client.</param>
|
|
||||||
public async Task Handle()
|
public async Task Handle()
|
||||||
{
|
{
|
||||||
if (Connected)
|
if (Connected)
|
||||||
|
@ -39,12 +38,15 @@ namespace PixelHub.Server
|
||||||
incoming = new StreamReader(client.GetStream());
|
incoming = new StreamReader(client.GetStream());
|
||||||
outgoing = new StreamWriter(client.GetStream()) { AutoFlush = true };
|
outgoing = new StreamWriter(client.GetStream()) { AutoFlush = true };
|
||||||
|
|
||||||
|
outgoing.WriteLine("Test message!");
|
||||||
|
|
||||||
string nextLine;
|
string nextLine;
|
||||||
while((nextLine = await incoming.ReadLineAsync()) != null)
|
while((nextLine = await incoming.ReadLineAsync()) != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Got message from client: '{0}'", nextLine.Trim());
|
Console.WriteLine("Got message from client: '{0}'", nextLine.Trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Connected = false;
|
Connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace PixelHub.Server
|
||||||
IPAddress.Parse("239.62.148.30"), port,
|
IPAddress.Parse("239.62.148.30"), port,
|
||||||
beaconWriter
|
beaconWriter
|
||||||
);
|
);
|
||||||
beacon.LocalIP = IPAddress.Parse("10.42.0.1");
|
beacon.LocalIP = IPAddress.Parse("192.168.0.5");
|
||||||
beacon.NetworkInterfaceName = "wlan0";
|
beacon.NetworkInterfaceName = "wlan0";
|
||||||
|
|
||||||
PixelHub server = new PixelHub(port, serverWriter);
|
PixelHub server = new PixelHub(port, serverWriter);
|
||||||
|
|
Reference in a new issue