renamed with nwn2ai prefix

This commit is contained in:
Crom (Thibaut CHARLES) 2015-04-17 21:36:14 +02:00
parent 4292f4b4de
commit 9a02c05f84
5 changed files with 34 additions and 20 deletions

View File

@ -17,7 +17,7 @@ using NWItemProperty = NWScript.NWScriptEngineStructure4;
namespace CLRScript
{
public partial class nwn2_ai_onmoduleload : CLRScriptBase, ICLRScriptImplementation
public partial class nwn2ai_onmoduleload : CLRScriptBase, ICLRScriptImplementation
{
/// <summary>
@ -118,7 +118,7 @@ namespace CLRScript
/// <returns>The cloned script object is returned.</returns>
public IGeneratedScriptProgram CloneScriptProgram()
{
return (IGeneratedScriptProgram)(new nwn2_ai_onmoduleload(this));
return (IGeneratedScriptProgram)(new nwn2ai_onmoduleload(this));
}
/// <summary>

View File

@ -28,15 +28,15 @@ using System.Net.Sockets;
namespace CLRScript
{
public partial class nwn2_ai_onmoduleload : CLRScriptBase, ICLRScriptImplementation, IGeneratedScriptProgram
public partial class nwn2ai_onmoduleload : CLRScriptBase, ICLRScriptImplementation, IGeneratedScriptProgram
{
public nwn2_ai_onmoduleload([In] NWScriptJITIntrinsics Intrinsics, [In] INWScriptProgram Host)
public nwn2ai_onmoduleload([In] NWScriptJITIntrinsics Intrinsics, [In] INWScriptProgram Host)
{
InitScript(Intrinsics, Host);
}
private nwn2_ai_onmoduleload([In] nwn2_ai_onmoduleload Other)
private nwn2ai_onmoduleload([In] nwn2ai_onmoduleload Other)
{
InitScript(Other);
@ -49,8 +49,14 @@ namespace CLRScript
//
public static Type[] ScriptParameterTypes = { };
StreamWriter debugFile;
public Int32 ScriptMain([In] object[] ScriptParameters, [In] Int32 DefaultReturnCode)
{
debugFile = File.AppendText("nwnx4\\customlog.txt");
Debug("====================================> Start");
sockBufferIn = new Queue<string>();
sockClients = new Dictionary<string,Socket>();
SocketConfigure();
@ -77,33 +83,36 @@ namespace CLRScript
sockServer.Bind(iep);
sockServer.Listen(10);
sockThread = new Thread(new ThreadStart(SockerHandler));
sockThread = new Thread(new ThreadStart(SocketHandler));
sockThread.Start();
}
void SockerHandler()
void SocketHandler()
{
while(true){
Socket sockClient = sockServer.Accept();
Debug("Accepting");
//Socket sockClient = sockServer.Accept();
sockServer.BeginAccept(new AsyncCallback(RequestHandler), sockServer);
}
}
void RequestHandler(IAsyncResult state)
{
Debug("Connection received");
//Socket listener = (Socket)state.AsyncState;
//Socket handler = listener.EndAccept(state);
Socket sockClient = sockServer.EndAccept(state);
//Socket sockClient = sockServer.EndAccept(state);
//Debug("Connection Accepted");
byte[] rawLength = new byte[4];
sockClient.Receive(rawLength);
//byte[] rawLength = new byte[4];
//sockClient.Receive(rawLength);
int length = rawLength[0]<<8 + rawLength[1];
byte[] rawData = new byte[length];
sockClient.Receive(rawData);
string data = Encoding.UTF8.GetString(rawData);
sockBufferIn.Enqueue(data);
//int length = rawLength[0]<<8 + rawLength[1];
//byte[] rawData = new byte[length];
//sockClient.Receive(rawData);
//string data = Encoding.UTF8.GetString(rawData);
//Debug("got data: "+data);
//sockBufferIn.Enqueue(data);
}
Socket sockServer;
@ -112,5 +121,10 @@ namespace CLRScript
//PNJ tag => Client socket
Dictionary<string, Socket> sockClients;
private void Debug(string msg){
debugFile.WriteLine(DateTime.Now.ToLongTimeString()+": "+msg);
debugFile.Flush();
}
}
}

View File

@ -8,8 +8,8 @@
<ProjectGuid>{D2787600-DE01-4E09-9F74-1A13F1ADB4E8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>nwn2_ai_onmoduleload</RootNamespace>
<AssemblyName>nwn2_ai_onmoduleload</AssemblyName>
<RootNamespace>nwn2ai_onmoduleload</RootNamespace>
<AssemblyName>nwn2ai_onmoduleload</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
@ -48,7 +48,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="nwn2_ai_onmoduleload.cs" />
<Compile Include="nwn2ai_onmoduleload.cs" />
<Compile Include="..\CLRScriptSDK\NWScriptActions.cs" />
<Compile Include="..\CLRScriptSDK\NWScriptConstants.cs" />
<Compile Include="..\CLRScriptSDK\NWScriptSupport.cs" />