//
// cocos2d::extension::WebSocket::onSocketCallback from 0x5ad306 to 0x5ad4ca (452 bytes)
//
// 1 xrefs:
// > cocos2d::extension::WebSocketCallbackWrapper::onSocketCallback @ 0x5ad4ea
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall cocos2d::extension::WebSocket::onSocketCallback(
int a1,
int a2,
unsigned int a3,
int a4,
const void *a5,
unsigned int a6)
{
int v8; // r3
_DWORD *i; // r5
_DWORD *v10; // r1
_DWORD *v11; // r5
int v12; // r0
int *v13; // r7
int v14; // r6
int v15; // r0
void *v16; // r11
void *v17; // r9
int v18; // r3
int v19; // r0
_DWORD *v20; // r7
int v21; // r0
int v22; // r5
_BYTE *v23; // r0
_BYTE *v24; // r3
void *v25; // r0
void *v26; // r3
if ( a3 == 8 )
{
if ( a5 && a6 )
{
v20 = (_DWORD *)operator new(8u);
*v20 = 3;
v20[1] = 0;
v21 = operator new(0xCu);
*(_DWORD *)v21 = 0;
v22 = v21;
*(_DWORD *)(v21 + 4) = 0;
*(_BYTE *)(v21 + 8) = 0;
if ( lws_frame_is_binary(a2) )
{
v23 = (_BYTE *)operator new[](a6);
*(_BYTE *)(v22 + 8) = 1;
v24 = v23;
}
else
{
v24 = (_BYTE *)operator new[](a6 + 1);
v24[a6] = 0;
*(_BYTE *)(v22 + 8) = 0;
}
v25 = memcpy(v24, a5, a6);
v10 = v20;
v26 = v25;
v12 = *(_DWORD *)(a1 + 20);
*(_DWORD *)v22 = v26;
*(_DWORD *)(v22 + 4) = a6;
v20[1] = v22;
goto LABEL_38;
}
return 0;
}
if ( a3 <= 8 )
{
if ( a3 == 3 )
{
v11 = (_DWORD *)operator new(8u);
*v11 = 2;
v11[1] = 0;
*(_DWORD *)(a1 + 4) = 1;
lws_callback_on_writable(a2);
v12 = *(_DWORD *)(a1 + 20);
v10 = v11;
LABEL_38:
cocos2d::extension::WsThreadHelper::sendMessageToUIThread(v12, (int)v10);
return 0;
}
if ( a3 != 4 )
{
if ( a3 == 1 )
goto LABEL_15;
return 0;
}
cocos2d::extension::WsThreadHelper::quitSubThread(*(_DWORD *)(a1 + 20));
if ( *(_DWORD *)(a1 + 4) == 3 )
return 0;
v10 = (_DWORD *)operator new(8u);
v10[1] = 0;
*(_DWORD *)(a1 + 4) = 3;
LABEL_30:
*v10 = 5;
goto LABEL_37;
}
if ( a3 != 28 )
{
if ( a3 == 33 )
{
if ( !*(_DWORD *)(a1 + 4) )
goto LABEL_15;
}
else if ( a3 == 10 )
{
pthread_mutex_lock((pthread_mutex_t *)(*(_DWORD *)(a1 + 20) + 64));
for ( i = **(_DWORD ***)(*(_DWORD *)(a1 + 20) + 56); i != *(_DWORD **)(*(_DWORD *)(a1 + 20) + 56); i = (_DWORD *)*i )
{
v13 = (int *)i[2];
if ( (unsigned int)*v13 <= 1 )
{
v14 = v13[1];
v15 = operator new[](*(_DWORD *)(v14 + 4) + 16);
v16 = (void *)(v15 + 16);
v17 = (void *)v15;
memset((void *)(v15 + 16), 0, *(_DWORD *)(v14 + 4));
memcpy(v16, *(const void **)v14, *(_DWORD *)(v14 + 4));
v18 = *v13;
if ( *v13 )
v18 = 1;
lws_write(a2, v16, *(_DWORD *)(v14 + 4), v18);
if ( *(_DWORD *)v14 )
{
operator delete[](*(void **)v14);
*(_DWORD *)v14 = 0;
}
operator delete((void *)v14);
operator delete[](v17);
}
operator delete(v13);
}
std::_List_base::_M_clear((_DWORD **)i);
v19 = *(_DWORD *)(a1 + 20);
*i = i;
i[1] = i;
pthread_mutex_unlock((pthread_mutex_t *)(v19 + 64));
lws_callback_on_writable(a2);
}
return 0;
}
v8 = *(_DWORD *)(a1 + 4);
if ( !v8 )
{
LABEL_15:
v10 = (_DWORD *)operator new(8u);
*v10 = 4;
v10[1] = 0;
*(_DWORD *)(a1 + 4) = 2;
LABEL_37:
v12 = *(_DWORD *)(a1 + 20);
goto LABEL_38;
}
if ( v8 == 2 )
{
v10 = (_DWORD *)operator new(8u);
v10[1] = 0;
goto LABEL_30;
}
return 0;
}