YGetNextEvent - event retrieving
#include <Y2/Y.h>
#include <Y2/Ylib.h>
int YGetNextEvent(
YConnection *connection,
YEvent *event,
Boolean block
)
The YGetNextEvent function gets the next (oldest or latest, if you will) event from the Y server.
If block is set to True, then the call will block untill an event is received.
If block is set to False, then the call will check if there are any events queued. If there is atleast one queued event (being the next/oldest/latest), its values will be coppied to the buffer pointed to by event and the function will return 1. If there were no events in the queue, then the function returns 0.
If you receive a YDisconnect or YShutdown event then the given YConnection con structure's connection would have been closed. You should call YCloseConnection on it immediatly afterwards to deallocated the structure formally.
The YGetNextEvent function returns the number of events received or 0.
#include <stdio.h>
#include <Y2/Y.h>
#include <Y2/Ylib.h>
int main(int argc, char *argv[])
{
YEvent event;
YConnection *con = YOpenConnection(
"/usr/sbin/starty",
"127.0.0.1:9433"
);
if(con == NULL)
return(1);
printf("Waiting for event...\n");
if(YGetNextEvent(
con, &event, True
) > 0)
printf(
"Got event type %i\n",
event.type
);
printf("Done.\n");
YCloseConnection(con, False);
YEvent(3) YPutBackEvent(3)