Various C# Script improvements

Move handling code in a separate file
Add caching ability for low-power devices (rpi..)
Use a distinct API with MCC.MethodName()
Stop script execution only on specific API calls
This commit is contained in:
ORelio 2015-08-23 18:51:24 +02:00
parent ca02c7f2e6
commit 3e2622fbb7
8 changed files with 407 additions and 159 deletions

View file

@ -9,8 +9,8 @@ if (args.Length > 0)
for (int i = 0; i < 5; i++)
{
int count = GetVarAsInt("test") + 1;
SetVar("test", count);
int count = MCC.GetVarAsInt("test") + 1;
MCC.SetVar("test", count);
SendHelloWorld(count, text);
SleepBetweenSends();
}
@ -21,15 +21,11 @@ for (int i = 0; i < 5; i++)
void SendHelloWorld(int count, string text)
{
/* Warning: Do not make more than one server-related call into a method
* defined as a script extension eg SendText or switching servers,
* as execution flow is not managed in the Extensions section */
SendText("Hello World no. " + count + ": " + text);
MCC.SendText("Hello World no. " + count + ": " + text);
}
void SleepBetweenSends()
{
LogToConsole("Sleeping for 5 seconds...");
MCC.LogToConsole("Sleeping for 5 seconds...");
Thread.Sleep(5000);
}