testing curl for android
This commit is contained in:
@@ -46,6 +46,7 @@ target_include_directories(native-lib PRIVATE
|
|||||||
../libs/tinyxml2
|
../libs/tinyxml2
|
||||||
../libs/yoga
|
../libs/yoga
|
||||||
../libs/stb
|
../libs/stb
|
||||||
|
../libs/curl/android/include
|
||||||
)
|
)
|
||||||
|
|
||||||
# add lib dependencies
|
# add lib dependencies
|
||||||
@@ -53,7 +54,9 @@ target_link_libraries(
|
|||||||
native-lib
|
native-lib
|
||||||
android
|
android
|
||||||
app-glue
|
app-glue
|
||||||
|
${CMAKE_SOURCE_DIR}/../libs/curl/android/armeabi-v7a/libcurl.a
|
||||||
EGL
|
EGL
|
||||||
GLESv3
|
GLESv3
|
||||||
log
|
log
|
||||||
|
z
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package="com.omigamedev"
|
package="com.omigamedev"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<application android:label="@string/app_name"
|
<application android:label="@string/app_name"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
|
|||||||
@@ -289,12 +289,46 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
|||||||
* android_native_app_glue. It runs in its own thread, with its own
|
* android_native_app_glue. It runs in its own thread, with its own
|
||||||
* event loop for receiving input events and doing other things.
|
* event loop for receiving input events and doing other things.
|
||||||
*/
|
*/
|
||||||
|
#include <curl/curl.h>
|
||||||
|
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||||
|
{
|
||||||
|
((std::string*)userp)->append((char*)contents, size * nmemb);
|
||||||
|
LOG("READ SOMETHIND");
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
int curl_test()
|
||||||
|
{
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res;
|
||||||
|
std::string readBuffer;
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if(curl) {
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
LOG("READ: %s", readBuffer.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG("READ FAILED");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
void android_main(struct android_app* state) {
|
void android_main(struct android_app* state) {
|
||||||
struct engine engine;
|
struct engine engine;
|
||||||
|
|
||||||
// Make sure glue isn't stripped.
|
// Make sure glue isn't stripped.
|
||||||
app_dummy();
|
app_dummy();
|
||||||
|
|
||||||
|
LOG("NETWORK TESTING...");
|
||||||
|
curl_test();
|
||||||
|
LOG("NETWORK TESTED");
|
||||||
|
|
||||||
memset(&engine, 0, sizeof(engine));
|
memset(&engine, 0, sizeof(engine));
|
||||||
state->userData = &engine;
|
state->userData = &engine;
|
||||||
state->onAppCmd = engine_handle_cmd;
|
state->onAppCmd = engine_handle_cmd;
|
||||||
|
|||||||
Reference in New Issue
Block a user