Exemple #1
0
static void CPROC Received( PCLIENT pc, POINTER buffer, size_t size )
{
	struct network_read_state *pns = (struct network_read_state *)GetNetworkLong( pc, 0 );
	if( !buffer )
	{
		pns = New( struct network_read_state );
		MemSet( pns, 0, sizeof( struct network_read_state ) );
		SetNetworkLong( pc, 0, (uintptr_t)pns );
		pns->bufsize = 4096;
		pns->buffer = Allocate( 4096 );
	}
Exemple #2
0
void OnEvent( PCLIENT pc, PTRSZVAL psv, POINTER buffer, int msglen )
{
	struct game_client *client = (struct game_client *)GetNetworkLong( pc, 0 );
   struct game_message *msg;
	if( json_parse_message( gsg.json_context, (CTEXTSTR)buffer, msglen, NULL, &msg ) )
	{
		switch( msg->MsgID )
		{
		case GameMessage_Hello:
         break;
		}

		json_dispose_message( msg );
	}
	else
	{
		// unhandled message received.
      RemoveClient( pc );
	}
}
Exemple #3
0
void OnClose( PCLIENT pc, PTRSZVAL psv )
{
   struct game_client *client = (struct game_client *)GetNetworkLong( pc, 0 );
}