Skip to content

Instantly share code, notes, and snippets.

@Stuyk
Created April 8, 2019 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stuyk/869b5f2ec7d8cdb66e0b9f8b703d0b9e to your computer and use it in GitHub Desktop.
Save Stuyk/869b5f2ec7d8cdb66e0b9f8b703d0b9e to your computer and use it in GitHub Desktop.
Websocket.cs is what you use in your resource. The rest are how to load StuykSocket.dll as a resource.
<meta>
<info name="StuykSocket" author="Stuyk" type="script" />
<script src="StuykSocket.dll"/>
<export class="StuykSocket" event="onSocketMessageRecieved" />
</meta>
Add this line:
<resource src="StuykSocket" />
public class Websocket : Script
{
public Websocket()
{
NAPI.Exported.StuykSocket.onSocketMessageRecieved += new ExportedEvent(OnMessageSocket);
}
private void OnMessageSocket(dynamic[] parameters)
{
string result = parameters[0] as string;
// This is the message you'll get from the program.
// You can split it up by spaces to create parameters.
// Switch statements to invoke functions and such.
Console.WriteLine(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment