81 lines
2.3 KiB
C#
81 lines
2.3 KiB
C#
//
|
|
// This script serves as a basis for new scripts. New scripts can copy this
|
|
// source file to start out.
|
|
//
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Runtime.InteropServices;
|
|
using System.Reflection;
|
|
using System.Reflection.Emit;
|
|
using CLRScriptFramework;
|
|
using NWScript;
|
|
using NWScript.ManagedInterfaceLayer.NWScriptManagedInterface;
|
|
|
|
using NWEffect = NWScript.NWScriptEngineStructure0;
|
|
using NWEvent = NWScript.NWScriptEngineStructure1;
|
|
using NWLocation = NWScript.NWScriptEngineStructure2;
|
|
using NWTalent = NWScript.NWScriptEngineStructure3;
|
|
using NWItemProperty = NWScript.NWScriptEngineStructure4;
|
|
|
|
using System.Threading;
|
|
using Grapevine.Server;
|
|
using System.IO;
|
|
using System.Net;
|
|
namespace CLRScript
|
|
{
|
|
public partial class nwn2_ai_onmoduleload : CLRScriptBase, ICLRScriptImplementation, IGeneratedScriptProgram
|
|
{
|
|
|
|
public nwn2_ai_onmoduleload([In] NWScriptJITIntrinsics Intrinsics, [In] INWScriptProgram Host)
|
|
{
|
|
InitScript(Intrinsics, Host);
|
|
}
|
|
|
|
private nwn2_ai_onmoduleload([In] nwn2_ai_onmoduleload Other)
|
|
{
|
|
InitScript(Other);
|
|
|
|
LoadScriptGlobals(Other.SaveScriptGlobals());
|
|
}
|
|
|
|
//
|
|
// Include the list of types for parameters to the main function here.
|
|
// An empty list means no parameters.
|
|
//
|
|
public static Type[] ScriptParameterTypes = { };
|
|
|
|
public Int32 ScriptMain([In] object[] ScriptParameters, [In] Int32 DefaultReturnCode)
|
|
{
|
|
server = new RESTServer("127.0.0.1", "8080", "http", "index.html", "C:\\nowhere", 1);
|
|
server.Start();
|
|
|
|
AssignCommand(OBJECT_SELF, delegate() { ActionSpeakString("Start!", TALKVOLUME_TALK); });
|
|
DelayCommand(0.5f, Heartbeat);
|
|
|
|
return DefaultReturnCode;
|
|
}
|
|
|
|
public void Heartbeat()
|
|
{
|
|
ActionSpeakString("hb", TALKVOLUME_TALK);
|
|
DelayCommand(0.5f, Heartbeat);
|
|
}
|
|
|
|
|
|
|
|
RESTServer server;
|
|
public sealed class MyResource : RESTResource
|
|
{
|
|
[RESTRoute]
|
|
public void HandleAllGetRequests(HttpListenerContext context)
|
|
{
|
|
SendTextResponse(context, "GET is a success!");
|
|
}
|
|
}
|
|
}
|
|
}
|