//
// cocos2d::extension::WebSocket::onSocketCallback from 0x18001a4d0 to 0x18001a855 (901 bytes)
//
// 5 xrefs:
// > sub_1800193C0 @ 0x18001940e
// > ??> @ 0x180031c30
// > ??> @ 0x180031c40
// > ??> @ 0x180032408
// > ??> @ 0x18004cc68
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:15:43 +0000
//
__int64 __fastcall cocos2d::extension::WebSocket::onSocketCallback(
__int64 a1,
__int64 a2,
int a3,
__int64 a4,
void *Src,
size_t Size)
{
__int64 v8; // rdx
__int64 v9; // rbx
__int64 v10; // rdx
_QWORD **v11; // rax
_QWORD *v12; // rbx
_QWORD *v13; // r15
__int64 v14; // r14
__int64 v15; // r13
_QWORD *v16; // rdi
_QWORD **v17; // rcx
_QWORD *v18; // rcx
_QWORD *v19; // rbx
__int64 v20; // r12
__int64 v21; // rdi
_BYTE *v22; // r14
char v23; // al
switch ( a3 )
{
case 1:
case 28:
case 33:
if ( a3 == 1 )
goto LABEL_9;
if ( a3 != 28 )
{
if ( a3 != 33 || *(_DWORD *)(a1 + 8) )
return 0;
LABEL_9:
v8 = sub_18001F040(0x10u);
*(_QWORD *)(v8 + 8) = 0;
*(_DWORD *)v8 = 4;
*(_DWORD *)(a1 + 8) = 2;
goto LABEL_28;
}
if ( !*(_DWORD *)(a1 + 8) )
goto LABEL_9;
if ( *(_DWORD *)(a1 + 8) == 2 )
{
v8 = sub_18001F040(0x10u);
*(_QWORD *)(v8 + 8) = 0;
*(_DWORD *)v8 = 5;
goto LABEL_28;
}
return 0;
case 3:
v9 = sub_18001F040(0x10u);
*(_QWORD *)(v9 + 8) = 0;
*(_DWORD *)v9 = 2;
*(_DWORD *)(a1 + 8) = 1;
lws_callback_on_writable(a2);
v8 = v9;
goto LABEL_28;
case 4:
*(_BYTE *)(*(_QWORD *)(a1 + 88) + 112LL) = 1;
if ( *(_DWORD *)(a1 + 8) == 3 )
return 0;
v8 = sub_18001F040(0x10u);
*(_QWORD *)(v8 + 8) = 0;
*(_DWORD *)(a1 + 8) = 3;
*(_DWORD *)v8 = 5;
goto LABEL_28;
case 8:
if ( !Src || !Size )
return 0;
v20 = sub_18001F040(0x10u);
*(_QWORD *)(v20 + 8) = 0;
*(_DWORD *)v20 = 3;
v21 = sub_18001F040(0x10u);
*(_QWORD *)v21 = 0;
*(_DWORD *)(v21 + 8) = 0;
*(_BYTE *)(v21 + 12) = 0;
if ( (unsigned int)lws_frame_is_binary(a2) )
{
v22 = (_BYTE *)sub_18001F33C(Size);
v23 = 1;
}
else
{
v22 = (_BYTE *)sub_18001F33C(Size + 1);
v22[Size] = 0;
v23 = 0;
}
*(_BYTE *)(v21 + 12) = v23;
memcpy(v22, Src, Size);
*(_QWORD *)v21 = v22;
v8 = v20;
*(_DWORD *)(v21 + 8) = Size;
*(_QWORD *)(v20 + 8) = v21;
LABEL_28:
sub_180019580(*(_QWORD *)(a1 + 88), v8);
return 0;
case 10:
pthread_mutex_lock(*(_QWORD *)(a1 + 88) + 80LL);
v10 = *(_QWORD *)(a1 + 88);
v11 = *(_QWORD ***)(v10 + 64);
v12 = (_QWORD *)**v11;
if ( v12 != *v11 )
{
do
{
v13 = (_QWORD *)v12[2];
if ( *(_DWORD *)v13 <= 1u )
{
v14 = v13[1];
v15 = sub_18001F33C(*(_DWORD *)(v14 + 8) + 16);
memset((void *)(v15 + 16), 0, *(int *)(v14 + 8));
memcpy((void *)(v15 + 16), *(const void **)v14, *(int *)(v14 + 8));
lws_write(a2, v15 + 16, *(int *)(v14 + 8), *(_DWORD *)v13 != 0);
if ( *(_QWORD *)v14 )
{
j_j_free(*(void **)v14);
*(_QWORD *)v14 = 0;
}
j_j_free((void *)v14);
j_j_free((void *)v15);
}
j_j_free(v13);
v10 = *(_QWORD *)(a1 + 88);
v12 = (_QWORD *)*v12;
}
while ( v12 != **(_QWORD ***)(v10 + 64) );
}
v16 = *(_QWORD **)(v10 + 64);
v17 = (_QWORD **)*v16;
**(_QWORD **)(*v16 + 8LL) = 0;
v18 = *v17;
if ( v18 )
{
do
{
v19 = (_QWORD *)*v18;
j_j_free(v18);
v18 = v19;
}
while ( v19 );
}
*(_QWORD *)*v16 = *v16;
*(_QWORD *)(*v16 + 8LL) = *v16;
v16[1] = 0;
pthread_mutex_unlock(*(_QWORD *)(a1 + 88) + 80LL);
lws_callback_on_writable(a2);
return 0;
default:
return 0;
}
}