![]() |
|
[A5] Event and socket messages ? |
dt65536
Member #15,540
March 2014
|
Hi everybody, I am beginning a new (game) project, and I'm using both Allegro and network communication for the first time. The documentation of Allegro is easy and complete so I have a good time using it, but I still have just notions of how a network works (I am still learning about what sockets are exactly). I am now at the point where I need the game client to retrieve data such as position of players sent from a server. Sadly, I couldn't find a similar question or an example about events and network, so I am referring to your wisdom. My questions are : I apologize if the terms I used aren't exact (I hope it's still understandable). Thanks in advance for your answers. edit : I omitted to mention I wish to use only C language (so no objects). |
Thomas Fjellstrom
Member #476
June 2000
![]() |
If you don't feel comfortable making your networking code feed an allegro event queue, you can use al_wait_for_event_timed or al_get_next_event, and handle your own waiting. -- |
dt65536
Member #15,540
March 2014
|
Thanks for your reply, Is there any project to one day support network communications and sockets as a part of Allegro (either as an addon or in the core) ? |
Thomas Fjellstrom
Member #476
June 2000
![]() |
If you go the thread route, you can send your own custom messages to your main loop's event queue to wake it up and handle whatever you need to handle. (see: al_init_user_event_source and al_emit_user_event) dt65536 said: I'm not sure how to create a loop that wakes the program up only if an event is sent or a message is received. event queue's will wake al_wait_for_event up when they get an event, no matter who sends the event. -- |
|