Add Lua function comm.socketServerSendBytes (resolves #2194)

takes a single param of an array-like table, casts each element to byte before
passing to ApiHawk
This commit is contained in:
YoshiRulz 2021-03-22 08:15:53 +10:00
parent 45488f2667
commit fafa29a2bf
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 10 additions and 0 deletions

View File

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using NLua;
namespace BizHawk.Client.Common
{
[Description("A library for communicating with other programs")]
@ -54,6 +57,13 @@ namespace BizHawk.Client.Common
return APIs.Comm.Sockets.SendString(SendString);
}
[LuaMethod("socketServerSendBytes", "sends a string to the Socket server")]
public int SocketServerSendBytes(LuaTable byteArray)
{
if (!CheckSocketServer()) return -1;
return APIs.Comm.Sockets.SendBytes(_th.EnumerateValues<double>(byteArray).Select(d => (byte) d).ToArray());
}
[LuaMethod("socketServerResponse", "receives a message from the Socket server")]
public string SocketServerResponse()
{