mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Testing Cotija comms
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -48,8 +48,8 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void GoWithLoad()
|
public void GoWithLoad()
|
||||||
{
|
{
|
||||||
var thread = new Thread(o =>
|
// var thread = new Thread(o =>
|
||||||
{
|
// {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
|
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
|
||||||
@@ -58,9 +58,9 @@ namespace PepperDash.Essentials
|
|||||||
//PortalSync = new PepperDashPortalSyncClient();
|
//PortalSync = new PepperDashPortalSyncClient();
|
||||||
|
|
||||||
//Temp Cotija testing
|
//Temp Cotija testing
|
||||||
//CotijaInterfaceController CotijaInterface = new CotijaInterfaceController("WebClient1");
|
CotijaInterfaceController CotijaInterface = new CotijaInterfaceController("WebClient1");
|
||||||
|
|
||||||
//CotijaInterface.InitializeClient("http://192.168.1.105");
|
//CotijaInterface.InitializeClientAndEventStream("http://localhost:3000/api/system/stream/abcdefgh");
|
||||||
|
|
||||||
Debug.Console(0, "Starting Essentials load from configuration");
|
Debug.Console(0, "Starting Essentials load from configuration");
|
||||||
ConfigReader.LoadConfig2();
|
ConfigReader.LoadConfig2();
|
||||||
@@ -77,8 +77,8 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
|
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
|
||||||
}
|
}
|
||||||
return null;
|
// return null;
|
||||||
}, null);
|
// }, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnablePortalSync(string s)
|
public void EnablePortalSync(string s)
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
public EssentialsHuddleSpaceFusionSystemController(EssentialsHuddleSpaceRoom room, uint ipId)
|
public EssentialsHuddleSpaceFusionSystemController(EssentialsHuddleSpaceRoom room, uint ipId)
|
||||||
: base(room.Key + "-fusion")
|
: base(room.Key + "-fusion")
|
||||||
{
|
{
|
||||||
|
|
||||||
Room = room;
|
Room = room;
|
||||||
|
|
||||||
IpId = ipId;
|
IpId = ipId;
|
||||||
|
|||||||
Binary file not shown.
@@ -14,23 +14,77 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
public class CotijaInterfaceController : Device
|
public class CotijaInterfaceController : Device
|
||||||
{
|
{
|
||||||
|
StreamReader Reader;
|
||||||
|
|
||||||
|
Crestron.SimplSharp.Net.Connection Connection;
|
||||||
|
|
||||||
public CotijaInterfaceController(string key) : base(key)
|
public CotijaInterfaceController(string key) : base(key)
|
||||||
{
|
{
|
||||||
CrestronConsole.AddNewConsoleCommand(InitializeClient, "InitializeHttpClient", "Initializes a new HTTP client connection to a specified URL", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(InitializeClientAndEventStream, "InitializeHttpClient", "Initializes a new HTTP client connection to a specified URL", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitializeClient(string url)
|
public void InitializeClientAndEventStream(string url)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
HttpClient webClient = new HttpClient();
|
HttpClient webClient = new HttpClient();
|
||||||
webClient.Verbose = true;
|
webClient.Verbose = true;
|
||||||
HttpClientRequest request = new HttpClientRequest();
|
HttpClientRequest request = new HttpClientRequest();
|
||||||
request.Url.Parse(url);
|
request.Url = new UrlParser(url);
|
||||||
request.Header.AddHeader(new HttpHeader("accept", "text/event-stream"));
|
request.Header.AddHeader(new HttpHeader("Accept", "text/event-stream"));
|
||||||
request.Header.SetHeaderValue("Expect", "");
|
request.KeepAlive = true;
|
||||||
webClient.DispatchAsync(request, (resp, err) =>
|
|
||||||
|
/// Experimenting with grabbing connection before the request
|
||||||
|
Connection = webClient.ConnectNew("192.168.1.120", 3000);
|
||||||
|
Debug.Console(1, this, "Connection Port: {0}", Connection.LocalEndPointPort);
|
||||||
|
Reader = new StreamReader(Connection);
|
||||||
|
Connection.OnBytesReceived += new EventHandler(DataConnection_OnBytesReceived);
|
||||||
|
|
||||||
|
/// Not sure if this is starting a new connection
|
||||||
|
webClient.DispatchAsync(request, StreamConnectionCallback);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
CrestronConsole.PrintLine(resp.ContentString);
|
Debug.Console(1, this, "Error Initializing Cotija client:\n{0}", e);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This callback happens but none of the events would fire (when not commented out)
|
||||||
|
void StreamConnectionCallback(HttpClientResponse resp, HTTP_CALLBACK_ERROR err)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Connection Port: {0}", resp.DataConnection.LocalEndPointPort);
|
||||||
|
Debug.Console(1, this, "Connections are equal {0}", resp.DataConnection == Connection);
|
||||||
|
Debug.Console(1, this, "Callback Fired");
|
||||||
|
//resp.DataConnection.OnBytesReceived += new EventHandler(DataConnection_OnBytesReceived);
|
||||||
|
//Debug.Console(1, this, "Received: '{0}'", resp.ContentString);
|
||||||
|
//resp.OnTransferEnd += new Crestron.SimplSharp.Net.TransferEndEventHandler(resp_OnTransferEnd);
|
||||||
|
//resp.OnTransferProgress += new Crestron.SimplSharp.Net.TransferProgressEventHandler(resp_OnTransferProgress);
|
||||||
|
//resp.OnTransferStart += new Crestron.SimplSharp.Net.TransferStartEventHandler(resp_OnTransferStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We could never get this event handler to fire
|
||||||
|
void DataConnection_OnBytesReceived(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "OnBytesReceived Event Fired.");
|
||||||
|
Debug.Console(1, this, "Event: Received: '{0}'", Reader.ReadToEnd());
|
||||||
|
}
|
||||||
|
|
||||||
|
//void resp_OnTransferStart(object sender, Crestron.SimplSharp.Net.TransferStartEventArgs e)
|
||||||
|
//{
|
||||||
|
// Debug.Console(1, this, "OnTransferStart");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void resp_OnTransferProgress(object sender, Crestron.SimplSharp.Net.TransferProgressEventArgs e)
|
||||||
|
//{
|
||||||
|
// Debug.Console(1, this, "OnTransferProgress");
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//void resp_OnTransferEnd(object sender, Crestron.SimplSharp.Net.TransferEndEventArgs e)
|
||||||
|
//{
|
||||||
|
// Debug.Console(1, this, "OnTransferEnd");
|
||||||
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user