Esempio n. 1
0
int gs_frames_next (GameServerFrameCursor* cursor, GameServerFrame* frame)
{
  if (cursor->pos == 0)
  {
    const unsigned char* posbuf = cursor->orig->buffer + cursor->pos;
   
    frame->ch1 = posbuf [0];
    frame->ch2 = posbuf [1];

    eclogger_fmt (LL_TRACE, "GAME_S", "frame", "received %i bytes [%i|%i]", cursor->orig->size, frame->ch1, frame->ch2);  
    
    
    /*
    if (posbuf [2] & C_BUFFER_SIZE_BIG)
    {
      EcBuffer_s buf = { cursor->orig->buffer + 8, cursor->orig->size - 8 };
      
      frame->content = ecbins_read(&buf, NULL);      
    }
    else if (posbuf [2] & C_BUFFER_SIZE_NORMAL)
    {
      EcBuffer_s buf = { cursor->orig->buffer + 6, cursor->orig->size - 6 };      

      frame->content = ecbins_read(&buf, NULL);      
    }
    else
    {
      EcBuffer_s buf = { cursor->orig->buffer + 5, cursor->orig->size - 5 };      
      
      frame->content = ecbins_read(&buf, NULL);      
    }
     */

    {
      EcBuffer_s buf = { cursor->orig->buffer + 2, cursor->orig->size - 2 };      
      
      frame->content = ecbins_read(&buf, NULL);      
    }
    
    cursor->pos = 1;
    
    return TRUE;
  }
  else
  {
    if (frame->content)
    {
      ecudc_destroy(&(frame->content));
    }
    
    return FALSE;
  }
}
Esempio n. 2
0
int main (int argc, char *argv[])
{
  EcMessageData d01;
  EcMessagesOutput o1;
  EcThread threads [21];
  int i;

  ecmessages_initialize ();
  
  ecmessages_add (0x01, 0x01, m01, NULL);
  ecmessages_add (0x02, 0x01, m02, NULL);
  
  ecmessages_broadcast (0x01, NULL, NULL);
  
  ecmessages_send (0x02, 0x01, NULL, NULL);
  ecmessages_send (0x01, 0x01, NULL, NULL);
  ecmessages_send (0x01, 0x02, NULL, NULL);
    
  d01.type = 0;
  d01.ref = 0;
  d01.content = ecudc_create (EC_ALLOC, ENTC_UDC_STRING, NULL);
  ecudc_setS (d01.content, "Hello World");

  ecmessages_broadcast (0x01, &d01, NULL);
  
  ecudc_destroy(EC_ALLOC, &(d01.content));
  
  o1 = ecmessages_output_create (c01, NULL, 0, 0);
  ecmessages_broadcast (0x01, NULL, o1);
  ecmessages_output_destroy (&o1);
  
  printf("threading !!!!\n");
  
  for (i = 0; i < 20; i++)
  {
    threads [i] = ecthread_new ();
  }
  
  for (i = 0; i < 20; i++)
  {
    ecthread_start(threads [i], th01, NULL);
  }

  for (i = 0; i < 20; i++)
  {
    ecthread_join(threads [i]);
    ecthread_delete(&(threads [i]));
  }
  
  ecmessages_deinitialize ();
  
  return 0;
}
Esempio n. 3
0
int _STDCALL th01 (void* ptr)
{
  int i;
  
  for (i = 0; i < 40; i++)
  {  
    EcMessageData d01;
    EcMessagesOutput o1;

    d01.type = 0;
    d01.ref = 0;
    d01.content = ecudc_create (EC_ALLOC, ENTC_UDC_STRING, NULL);
    ecudc_setS (d01.content, "Hello Thread");
    
    o1 = ecmessages_output_create (c01, NULL, 0, 0);
    ecmessages_broadcast (0x01, &d01, o1);
    ecmessages_output_destroy (&o1);

    ecudc_destroy(EC_ALLOC, &(d01.content));    
  }  
  
  return 0;
}