lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, May 16, 2022 at 11:29:32AM +0200, Fero Dali wrote:
> I have make a small program with AndroLua and now I want to make that
> a separate app. I have made that and it run fine as separate app. But
> I also want to disable creating incomming internet port 3333 (I changed
> it for now to another number). How do I disable opening that port?
> 
> Fero Dali

Suprisingly very small change was needed to disable internet connection.
In file app/src/main/java/sk/kottman/androlua//Lua.java

-			L = newState(true);
+			L = newState(false);

And some minor changes for this to work without app to throw exeption
after app close.

Or you can remove whole function
private class ServerThread extends Thread {}
class and also 3 mentions of serverThread variable. I belive I prefer
this way more.

Here folow the whole patch (made against Steve Donovan repository
https://github.com/stevedonovan/AndroLua) of the first method:

Do not accept internet connection to connect to lua
---
 app/src/main/java/sk/kottman/androlua//Lua.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/sk/kottman/androlua//Lua.java b/app/src/main/java/sk/kottman/androlua//Lua.java
index 0fe2f6f..927d020 100644
--- a/app/src/main/java/sk/kottman/androlua//Lua.java
+++ b/app/src/main/java/sk/kottman/androlua//Lua.java
@@ -29,7 +29,7 @@ public class Lua extends Service {
 	static final StringBuilder output = new StringBuilder();
 
 	Handler handler;
-	static ServerThread serverThread;
+	static ServerThread serverThread = null;
 	
 	// the binder just returns this service...
 	public class LocalBinder extends Binder {
@@ -143,7 +143,7 @@ public class Lua extends Service {
 		log("starting Lua service");
 		if (L == null) {
 			main_instance = this;
-			L = newState(true);
+			L = newState(false);
 			setGlobal("service",this);
 		}
 		
@@ -204,7 +204,9 @@ public class Lua extends Service {
 	public void onDestroy() {
 		super.onDestroy();
 		log("destroying Lua service");
-		serverThread.close(); 
+		if (serverThread != null) {
+			serverThread.close();
+		}
 		L.close();
 		L = null;
 	}
-- 
2.36.0