I wrote a wifi application which communicates with my pc.
How can i send a message to my pc when the application is left (HOME --> yes)? I know how to send messages but i dont know how i know that the application is left.
Send message over wlan on exiting game
You should already know how to setup a callback thread...if not refer to the file "pspdev\psp\sdk\samples\gu\common\callbacks.c".
In function exitCallback() insert your own code:
Grab any other wifi specific code from sdk examples....
Good luck,
jean
In function exitCallback() insert your own code:
Code: Select all
int exitCallback(int arg1, int arg2, void *common)
{
// do whatever you want here
exitRequest = 1; // main program loops should check for exitRequest
return 0;
}
void main()
{
while(!exitRequest)
{
// ...
}
sceKernelExitGame();
}
Good luck,
jean
Code: Select all
int exit_callback(int arg1, int arg2, void *common)
{
write(new, "exiting", strlen("exiting"));
sceKernelExitGame();
return 0;
}
....i bet it's not "exactly" the same.
1) don't know of all the code around to register the exit handler you wrote
2) you should NOT use sceKernelExitGame() from inside the exit handler, but instead accordingly set a variable that main loop checks against.
3) you start a communication routine a millisecond before the program context gets cleaned because of the issued exit command...At least put a sleep after the string printout.
PS: if you post some critical points of your code, this could help us helping you.
1) don't know of all the code around to register the exit handler you wrote
2) you should NOT use sceKernelExitGame() from inside the exit handler, but instead accordingly set a variable that main loop checks against.
3) you start a communication routine a millisecond before the program context gets cleaned because of the issued exit command...At least put a sleep after the string printout.
PS: if you post some critical points of your code, this could help us helping you.
Code: Select all
int exit_callback(int arg1, int arg2, void *common)
{
write(new, "exiting", strlen("exiting"));
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread,
0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int net_thread(SceSize args, void *argp)
{
//All my code in here
}
int main(int argc, char **argv)
{
SceUID thid;
SetupCallbacks();
pspDebugScreenInit();
# ifdef PSPFW3
sceUtilityLoadNetModule(1);
sceUtilityLoadNetModule(3);
# else
if (pspSdkLoadInetModules() < 0) {
CenterPrintF(RED, 0, "Not able to load network modules!\n");
sceKernelSleepThread();
}
# endif
thid = sceKernelCreateThread("net_thread", net_thread, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);
if(thid < 0)
{
printf("Thread could not be created\n");
sceKernelSleepThread();
}
sceKernelStartThread(thid, 0, NULL);
sceKernelExitDeleteThread(0);
return 0;
}