From fafa29a2bf876139e24abd19566033172466e212 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 22 Mar 2021 08:15:53 +1000 Subject: [PATCH] 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 --- .../lua/CommonLibs/CommLuaLibrary.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs b/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs index d81d9767b6..94e362220a 100644 --- a/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs +++ b/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs @@ -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(byteArray).Select(d => (byte) d).ToArray()); + } + [LuaMethod("socketServerResponse", "receives a message from the Socket server")] public string SocketServerResponse() {