-
Notifications
You must be signed in to change notification settings - Fork 53
Application upgrade from Silgy 3.x to 4.0
Silgy 4.0 API is more clear and consistent than the previous one. But it also means that it's not backward compatible. Differences are slight but nevertheless the applications need to be converted.
This is the short guide to help you with converting existing Silgy application to version 4.0.
If you had any trouble with this process, don't hesitate to ask: silgy.help@gmail.com.
Most applications will probably require only the first three steps.
-
Rename engine callbacks & update signatures
The easiest way to complete this might be by opening new silgy_app.cpp and copying and pasting new functions' names with their signatures.
-
app_process_req
→silgy_app_main
-
app_init
→silgy_app_init
-
app_uses_init
→silgy_app_session_init
-
app_luses_init
→silgy_app_user_login
-
app_uses_reset
→silgy_app_session_done
-
app_done
→silgy_app_done
-
-
You need to add a definition for silgy_app_user_logout():
void silgy_app_user_logout(int ci) { }
-
In
silgy_app_main()
replace return values with corresponding RES_STATUS(), i.e.:return ERR_NOT_FOUND; // old code RES_STATUS(404); // new code
-
app_uses_reset()
was using user session index (usi
). Nowsilgy_app_session_done()
uses connection index (ci
), so you can use US and AUS macros like in any other function. Additionally, you don't need to reset any data in engine session (US
) as this will be zero-ed by the engine. You can read more about sessions in Silgy here. -
If you were using
app_gen_page_msg()
to render your own custom error page, you need now to define:void silgy_app_error_page(int ci, int code) { // your code here }
You also need to add APP_ERROR_PAGE switch to
silgy_app.h
. -
If you were using
app_get_msg_str()
to provide your error messages, you now need to add them in silgy_app_init() using silgy_add_message().
If you are using ASYNC module, there are couple of additional steps:
-
Rename app_async_done to silgy_app_continue.
-
Replace macro
S
with SVC. -
Replace
err_code
withASYNC_ERR_CODE
.
-
Rename silgy_services.cpp to silgy_svc.cpp. Remember about ms script.
-
Rename engine callbacks & update signatures
-
services_init
→silgy_svc_init
-
service_app_process_req
→silgy_svc_main
-
services_done
→silgy_svc_done
-
-
Replace macro
S
with SVC. -
Replace silgy_svc_main's returns with setting the ASYNC_ERR_CODE.