This commit is contained in:
SongWei 2020-02-16 18:41:39 +11:00
parent 660df677e6
commit 620a8de744
3 changed files with 44 additions and 39 deletions

View File

@ -1,17 +1,8 @@
diag_log "leoext: try to initialize..."; diag_log "leoext: try to initialize...";
leoext_stop = false;
_return = "libleoext" callExtension "foooo"; _return = "libleoext" callExtension "foooo";
execVM "\leoservermod\marker.sqf"; execVM "\leoservermod\marker.sqf";
leoext_stop = false;
[] spawn {
while {!leoext_stop} do {
sleep 1;
private _markers = call leoext_map_markers_information;
private _units = call leoext_units_pos;
"libleoext" callExtension ["foo", [[_markers, _units]]];
};
}
diag_log format ["leoext: initialize complete! return: %1", _return]; diag_log format ["leoext: initialize complete! return: %1", _return];

View File

@ -26,4 +26,17 @@ leoext_units_pos = {
} forEach allUnits; } forEach allUnits;
_units_pos; _units_pos;
}; };
leoext_markers_start = {
[] spawn {
while {!leoext_stop} do {
sleep 1;
private _markers = call leoext_map_markers_information;
private _units = call leoext_units_pos;
"libleoext" callExtension ["foo", [[_markers, _units]]];
};
};
};
call leoext_markers_start;

View File

@ -86,33 +86,34 @@
(,(concatenate 'string "^" +static-prefix+ ".*$") ,#'serve-static-file) (,(concatenate 'string "^" +static-prefix+ ".*$") ,#'serve-static-file)
(nil ,#'route-not-found))) (nil ,#'route-not-found)))
(if (not (find-package 'swank))
(sb-thread:make-thread (sb-thread:make-thread
(lambda () (lambda ()
(woo:run (woo:run
(lambda (env) (lambda (env)
;;(print env) ;;(print env)
;;(print (type-of env)) ;;(print (type-of env))
(if (eq :post (getf env :request-method)) (if (eq :post (getf env :request-method))
(let* ((post-stream (getf env :raw-body)) (let* ((post-stream (getf env :raw-body))
(char-stream (flexi-streams:make-flexi-stream (char-stream (flexi-streams:make-flexi-stream
post-stream post-stream
:external-format :utf-8))))) :external-format :utf-8)))))
;(format t (read-line char-stream)))) ;(format t (read-line char-stream))))
;(format t "dispatching...") ;(format t "dispatching...")
(let ((route-function (dispatch (getf env :request-uri) +dispatch-table+))) (let ((route-function (dispatch (getf env :request-uri) +dispatch-table+)))
(format t "method:~A uri:~A route: ~A~%" (format t "method:~A uri:~A route: ~A~%"
(getf env :request-method) (getf env :request-method)
(getf env :request-uri) (getf env :request-uri)
route-function) route-function)
(funcall route-function env))) (funcall route-function env)))
:port 5000 :port 5000
:address "0.0.0.0")) :address "0.0.0.0"))
:name "webserver")) :name "webserver")
(sb-thread:list-all-threads)
(mapcar #'sb-thread:terminate-thread (if (find-package 'swank)
(remove-if-not (mapcar #'sb-thread:terminate-thread
(lambda (thread) (remove-if-not
(string= "webserver" (sb-thread:thread-name thread))) (lambda (thread)
(sb-thread:list-all-threads))) (string= "webserver" (sb-thread:thread-name thread)))
(sb-thread:list-all-threads))))