This commit is contained in:
SongWei 2020-02-15 20:35:42 +11:00
parent 8879bb85de
commit 65177aef43
4 changed files with 39 additions and 5 deletions

12
c/lib.c
View File

@ -27,6 +27,13 @@ int RVExtensionArgs(char *output, int outputSize,
const char *function,
const char **argv, int argc)
{
if(argc < 1) {
printf("leoext: need at least 1 argument to post\n");
return 101; // SYNTAX_ERROR_WRONG_PARAMS_SIZE
}
const char* output_string = argv[0];
CURL *curl;
CURLcode res;
@ -38,7 +45,7 @@ int RVExtensionArgs(char *output, int outputSize,
data. */
curl_easy_setopt(curl, CURLOPT_URL, "http://localhost:5000/post-test");
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "Arma3 request!");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, output_string);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
@ -56,5 +63,6 @@ int RVExtensionArgs(char *output, int outputSize,
void RVExtensionVersion(char *output, int outputSize)
{
curl_global_init(CURL_GLOBAL_ALL);
strncpy_safe(output, "Leo-Extension v0.1", outputSize);
printf("leoext loaded!\n");
strncpy_safe(output, "leoext v0.1", outputSize);
}

0
front/index.js Normal file
View File

11
front/package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "leoservermod_frontend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT"
}

View File

@ -2,6 +2,7 @@
(ql:quickload :flexi-streams)
(ql:quickload :file-types)
(ql:quickload :cl-ppcre)
(ql:quickload :cl-json)
(load "utils.lisp")
(defparameter +static-directory+ "~/arma3/static/")
@ -31,11 +32,19 @@
`(200 (:content-type ,mime-string) ,file-path))
(route-not-found))))
(defparameter *marker-info*
'(("Terminal" "mil_start" "ColorRed" (14648.7 16756.7 0))
("Small Island" "mil_objective" "ColorBlue" (8443.6 25118.3 0))
("Molos Airfield" "mil_marker" "ColorGreen" (27096.1 24840.6 0))))
(defun route-display-post (env)
(let* ((decoded-stream
(flex:make-flexi-stream (getf env :raw-body) :external-format :utf-8))
(result (read-string-stream decoded-stream)))
(format t "~&post body:~A~%" result)
(body (read-string-stream decoded-stream)))
(format t "~&post body:~A~%" body)
(let ((parsed (json:decode-json-from-string body)))
(setf *marker-info* parsed)
(print parsed))
(route-hello-world nil)))
(defun dispatch (request-path dispatch-table)
@ -78,5 +87,11 @@
(getf env :request-method)
(getf env :request-uri)
route-function)
(funcall route-function env)))))))
(funcall route-function env)))))
:name "webserver"))
(defparameter *web* (car (sb-thread:list-all-threads)))
(list *web*)
(sb-thread:terminate-thread *web*)