Created
April 8, 2019 12:47
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta> | |
<info name="StuykSocket" author="Stuyk" type="script" /> | |
<script src="StuykSocket.dll"/> | |
<export class="StuykSocket" event="onSocketMessageRecieved" /> | |
</meta> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this line: | |
<resource src="StuykSocket" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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