Rework dynamic and procedure function call
This commit is contained in:
parent
dab5de5edb
commit
e8651f7602
1 changed files with 51 additions and 25 deletions
76
lweb.pbi
76
lweb.pbi
|
@ -184,6 +184,9 @@ Module lhs_web
|
|||
PrototypeC WebHandler_Get(handler_Map_JSON.s)
|
||||
PrototypeC WebHandler_Post(handler_Map_JSON.s, ContentString.s)
|
||||
PrototypeC WebHandler_Universal(handler_Map_JSON.s, ContentString.s)
|
||||
PrototypeC.s WebHandler_i_Get(handler_Map_JSON.s)
|
||||
PrototypeC.s WebHandler_i_Post(handler_Map_JSON.s, ContentString.s)
|
||||
PrototypeC.s WebHandler_i_Universal(handler_Map_JSON.s, ContentString.s)
|
||||
|
||||
|
||||
;********************************
|
||||
|
@ -206,6 +209,7 @@ Module lhs_web
|
|||
Declare.s file_check(thread_requested.s, hostid.s)
|
||||
Declare.s call_request_string(RequestString.s, Info.i=#get_handler_procedure)
|
||||
Declare call_request(RequestString.s, Info.i=#get_handler_procedure)
|
||||
Declare.s call_function(ToCallType.i, ToCall.i, Map Header.s(), PostMapString.s ="")
|
||||
Declare advanced_register_handler(RequesterString.s, Permament.i = 0, Library.s = "", Host.s = "")
|
||||
Declare.s Work_Post_ToJSON_multipart_form_data(ContentLength.i, MemorSize.i, Memory.i)
|
||||
Declare.s Work_Post_ToJSON_x_www_form_urlencoded(ContentLength.i, MemorSize.i, Memory.i)
|
||||
|
@ -373,11 +377,22 @@ Module lhs_web
|
|||
current_register_proto = #handler_proto_post
|
||||
Case "Universal"
|
||||
current_register_proto = #handler_proto_universal
|
||||
Case "GET_int"
|
||||
current_register_proto = #handler_proto_i_get
|
||||
Case "POST_int"
|
||||
current_register_proto = #handler_proto_i_post
|
||||
Case "Universal_int"
|
||||
current_register_proto = #handler_proto_i_universal
|
||||
EndSelect
|
||||
|
||||
ldl::Logging("react:"+current_register_react+" file:"+configuration\hosts()\dynamichandler()\file+" Host ID:"+MapKey(configuration\hosts()))
|
||||
register_client_handler(current_register_react, current_lib_function, current_register_proto, current_register_type, MapKey(configuration\hosts()))
|
||||
advanced_register_handler(current_register_react, current_lib_perm, configuration\hosts()\dynamichandler()\file, MapKey(configuration\hosts()))
|
||||
If FindString(configuration\hosts()\dynamichandler()\functiontype, "_int")
|
||||
register_client_handler(current_register_react, current_lib_function, current_register_proto, current_register_type, MapKey(configuration\hosts()))
|
||||
Else
|
||||
register_client_handler(current_register_react, current_lib_function, current_register_proto, current_register_type, MapKey(configuration\hosts()))
|
||||
advanced_register_handler(current_register_react, current_lib_perm, configuration\hosts()\dynamichandler()\file, MapKey(configuration\hosts()))
|
||||
EndIf
|
||||
|
||||
If current_lib_close = 1
|
||||
CloseLibrary(current_lib)
|
||||
EndIf
|
||||
|
@ -691,17 +706,8 @@ Module lhs_web
|
|||
|
||||
If ToCall > 0 ;Dann ist eine Funktion hinterlegt und zulässig aufgerufen zu werden.
|
||||
;{ Dynamischer WebHandler
|
||||
Header_string = MapToJSONString(Header())
|
||||
Select ToCallType
|
||||
Case #handler_proto_universal
|
||||
Define.WebHandler_Universal ToCallProcedure = ToCall
|
||||
Handler_Response_Adress = ToCallProcedure(Header_string, "")
|
||||
Handler_Response = PeekS(Handler_Response_Adress)
|
||||
Case #handler_proto_get
|
||||
Define.WebHandler_Get ToCallProcedureGet = ToCall
|
||||
Handler_Response_Adress = ToCallProcedureGet(Header_string)
|
||||
Handler_Response = PeekS(Handler_Response_Adress)
|
||||
EndSelect
|
||||
Handler_Response = call_function(ToCallType, ToCall, Header())
|
||||
|
||||
If call_request(Host_call + thread_requested, #get_handler_library_perm) = 0 And Library_ID <> 0
|
||||
CloseLibrary(Library_ID)
|
||||
EndIf
|
||||
|
@ -869,18 +875,7 @@ Module lhs_web
|
|||
If ToCall > 0 ;A dynamic webhandler is available, call.
|
||||
;{ Dynamic webhandler.
|
||||
|
||||
Header_string = MapToJSONString(Header())
|
||||
Select ToCallType
|
||||
Case #handler_proto_universal
|
||||
Define.WebHandler_Universal ToCallProcedure_Universal = ToCall
|
||||
Handler_Response_Adress = ToCallProcedure_Universal(Header_string, PostMapString )
|
||||
ldl::Logging("Response Address:"+Str(Handler_Response_Adress))
|
||||
Handler_Response = PeekS(Handler_Response_Adress)
|
||||
Case #handler_proto_post
|
||||
Define.WebHandler_Post ToCallProcedure_Post = ToCall
|
||||
Handler_Response_Adress = ToCallProcedure_Post(Header_string, PostMapString)
|
||||
Handler_Response = PeekS(Handler_Response_Adress)
|
||||
EndSelect
|
||||
Handler_Response = call_function(ToCallType, ToCall, Header(), PostMapString)
|
||||
If call_request(Host_call + thread_requested, #get_handler_library_perm) = 0 And Library_ID <> 0
|
||||
CloseLibrary(Library_ID)
|
||||
EndIf
|
||||
|
@ -1379,6 +1374,37 @@ Module lhs_web
|
|||
m_request(Host+Route)\library = Library
|
||||
EndProcedure
|
||||
|
||||
Procedure.s call_function(ToCallType.i, ToCall.i, Map Header.s(), PostMapString.s ="")
|
||||
Define.i Handler_Response_Adress
|
||||
Define.s Handler_Response, Header_string
|
||||
Header_string = MapToJSONString(Header())
|
||||
Select ToCallType
|
||||
Case #handler_proto_universal
|
||||
Define.WebHandler_Universal ToCallProcedure_Universal = ToCall
|
||||
Handler_Response_Adress = ToCallProcedure_Universal(Header_string, PostMapString )
|
||||
ldl::Logging("Response Address:"+Str(Handler_Response_Adress))
|
||||
Handler_Response = PeekS(Handler_Response_Adress)
|
||||
Case #handler_proto_get
|
||||
Define.WebHandler_Get ToCallProcedureGet = ToCall
|
||||
Handler_Response_Adress = ToCallProcedureGet(Header_string)
|
||||
Handler_Response = PeekS(Handler_Response_Adress)
|
||||
Case #handler_proto_post
|
||||
Define.WebHandler_Post ToCallProcedure_Post = ToCall
|
||||
Handler_Response_Adress = ToCallProcedure_Post(Header_string, PostMapString)
|
||||
Handler_Response = PeekS(Handler_Response_Adress)
|
||||
Case #handler_proto_i_universal
|
||||
Define.WebHandler_i_Universal ToCallProcedure_i_Universal = ToCall
|
||||
Handler_Response = ToCallProcedure_i_Universal(Header_string, PostMapString )
|
||||
Case #handler_proto_i_get
|
||||
Define.WebHandler_i_get ToCallProcedure_i_get = ToCall
|
||||
Handler_Response = ToCallProcedure_i_get(Header_string)
|
||||
Case #handler_proto_i_post
|
||||
Define.WebHandler_i_Universal ToCallProcedure_i_post = ToCall
|
||||
Handler_Response = ToCallProcedure_i_post(Header_string, PostMapString )
|
||||
EndSelect
|
||||
ProcedureReturn Handler_Response
|
||||
EndProcedure
|
||||
|
||||
Procedure count_client(Type.i, Countchange.i)
|
||||
Select Type
|
||||
Case #client_HTTP
|
||||
|
|
Loading…
Reference in a new issue