wikiti / extension-networking

Library developed for OpenFL to facilitate connections between applications, using TCP sockets, and following the scheme of event-driven programming.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I upload the server part on my VPS to run forever ?

VishwasGagrani opened this issue · comments

Hope you don't mind as I have got many questions ( not issues ).
I know how to compile the haxe files. But I am not sure about how to use it as server on my VPS
How can I upload the server part on my VPS to run it forever?
Would it be feasible to use it for production? For Android?
Is it possible to make the client files kept on a web-hosting to communicate with the VPS having the server file?

Hello @VishwasGagrani !

I'll try to answer your questions as accurate as I can:

I know how to compile the haxe files. But I am not sure about how to use it as server on my VPS

You can compile the server-side project as a regular openfl project, using the <window hidden="true" /> directive on application.xml to create a headless application, and run that as your server.

For example, with these changes on examples/basic-example:

diff --git a/examples/basic-example/project.xml b/examples/basic-example/project.xml
index 00ccac3..9751f05 100644
--- a/examples/basic-example/project.xml
+++ b/examples/basic-example/project.xml
@@ -8,6 +8,7 @@
 
   <window background="#1a1a1a" fps="60" />
   <window orientation="landscape" vsync="false" antialiasing="0" if="cpp" />
+  <window hidden="true" />
 
   <!-- classpath, haxe libs -->
   <source path="src" />
diff --git a/examples/basic-example/src/Main.hx b/examples/basic-example/src/Main.hx
index ff2a054..dfdedba 100644
--- a/examples/basic-example/src/Main.hx
+++ b/examples/basic-example/src/Main.hx
@@ -31,7 +31,20 @@ class Main extends Sprite {
    */
   public function new() {
     super();
+
+    trace("Starting basic-example");
     setupMenuButtons();
+
+    for (arg in Sys.args()) {
+      if (arg == "-client") {
+        runClient();
+        break;
+      }
+      else if (arg == "-server") {
+        runServer();
+        break;
+      }
+    }
   }
 
   /*

You may run two instances of the example with different arguments, and see how they connect:

> openfl build linux

# On terminal 1
> openfl run linux -- -client

# On terminal 2
> openfl run linux -- -server

How can I upload the server part on my VPS to run it forever?

I don't know. It depends on your VPS. If it's a linux machine, and you can connect via SSH, you may want to use something like tmux.

Since this is out of the scope of this library, you'll have to do your own research.

Would it be feasible to use it for production? For Android?

I don't know if there are any projects using this library on production. I haven't fully tested, nor give any warranty that it will work properly according to its MIT license. You may be the first one to test it on a production environment tho 😄

Is it possible to make the client files kept on a web-hosting to communicate with the VPS having the server file?

As stated on the wiki, this library supports flash projects, but I think its end of life is very close, so it may not be suitable for your needs.


Good luck!

Thanks. I will try to use it as per your description.