mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-12 19:24:43 +00:00
Started class for server, but did not get far yet
This commit is contained in:
Binary file not shown.
25
Pepperdash Core/Pepperdash Core/Comm/DynamicTCPServer.cs
Normal file
25
Pepperdash Core/Pepperdash Core/Comm/DynamicTCPServer.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash_Core.Comm
|
||||
{
|
||||
public class DynamicTCPServer
|
||||
{
|
||||
public bool Secure { get; set; }
|
||||
public ushort uSecure
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == 1)
|
||||
Secure = true;
|
||||
else if (value == 0)
|
||||
Secure = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,19 @@ namespace SecureTCP.SecureTCP.Client
|
||||
set { Port = Convert.ToInt32(value); }
|
||||
}
|
||||
|
||||
public bool RequiresPresharedKey { get; set; }
|
||||
|
||||
public ushort uRequiresPresharedKey
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == 1)
|
||||
RequiresPresharedKey = true;
|
||||
else
|
||||
RequiresPresharedKey = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module
|
||||
/// </summary>
|
||||
@@ -218,7 +231,7 @@ namespace SecureTCP.SecureTCP.Client
|
||||
Debug.Console(1, Debug.ErrorLogLevel.Warning, "GenericSecureTcpClient '{0}': Invalid port", Key);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(SharedKey))
|
||||
if (string.IsNullOrEmpty(SharedKey) && RequiresPresharedKey)
|
||||
{
|
||||
Debug.Console(1, Debug.ErrorLogLevel.Warning, "GenericSecureTcpClient '{0}': No Shared Key set", Key);
|
||||
return;
|
||||
@@ -230,7 +243,8 @@ namespace SecureTCP.SecureTCP.Client
|
||||
try
|
||||
{
|
||||
DisconnectCalledByUser = false;
|
||||
WaitingForSharedKeyResponse = true;
|
||||
if(RequiresPresharedKey)
|
||||
WaitingForSharedKeyResponse = true;
|
||||
SocketErrorCodes error = Client.ConnectToServer();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -265,7 +279,7 @@ namespace SecureTCP.SecureTCP.Client
|
||||
{
|
||||
var bytes = client.IncomingDataBuffer.Take(numBytes).ToArray();
|
||||
var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
||||
if (WaitingForSharedKeyResponse)
|
||||
if (WaitingForSharedKeyResponse && RequiresPresharedKey)
|
||||
{
|
||||
if (str != (SharedKey + "\n"))
|
||||
{
|
||||
@@ -308,8 +322,6 @@ namespace SecureTCP.SecureTCP.Client
|
||||
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
//if (Debug.Level == 2)
|
||||
// Debug.Console(2, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
||||
Client.SendData(bytes, bytes.Length);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="CommunicationExtras.cs" />
|
||||
<Compile Include="Comm\ControlPropertiesConfig.cs" />
|
||||
<Compile Include="Comm\DynamicTCPServer.cs" />
|
||||
<Compile Include="Comm\eControlMethods.cs" />
|
||||
<Compile Include="Comm\FINISH CommStatic.cs" />
|
||||
<Compile Include="Comm\CommunicationGather.cs" />
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -10,8 +10,8 @@
|
||||
<ArchiveName />
|
||||
</RequiredInfo>
|
||||
<OptionalInfo>
|
||||
<CompiledOn>3/10/2017 6:22:56 PM</CompiledOn>
|
||||
<CompilerRev>1.0.6278.33087</CompilerRev>
|
||||
<CompiledOn>3/13/2017 5:30:30 PM</CompiledOn>
|
||||
<CompilerRev>1.0.6281.19814</CompilerRev>
|
||||
</OptionalInfo>
|
||||
<Plugin>
|
||||
<Version>Crestron.SIMPLSharp, Version=2.0.52.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
MainAssembly=PepperDash_Core.dll:79619d005133babcf49ba6c3bbc3de28
|
||||
MainAssembly=PepperDash_Core.dll:bbf10e2b8fa14d4d571eeafc3bffb1a3
|
||||
MainAssemblyMinFirmwareVersion=1.007.0017
|
||||
MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e
|
||||
ü
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user