[Vala] vala, glib and zeromq



I don't know if it can be useful but I write few lines of code to easy
integrate zeromq in glib mainloop.

Source code and examples (not so much) are in
https://bitbucket.org/michele_dionisio/easyzmq/


I also write .vapi file and asynchronous function so it is possible to
write vala code like:


async void mainasync () {
  try {
    var req1 = new EasyZmq.ZmqSource.Req ();
    req1.Connect ("tcp://127.0.0.1:5555");

    unowned uint8[] bufout = null;
    bool more = false;

    yield req1.SendReq_async (10000, "pippo req1".data, out bufout, out more);

    stdout.printf ("req1: %.*s more: %d\n", bufout.length, (string)
bufout, (int) more);
  } catch (EasyZmq.Error er) {
    stdout.printf ("error connect\n");
  }
}

void main () {
  MainLoop loop = new MainLoop ();
  EasyZmq.Init ();

  mainasync.begin ((obj, res) => {
    mainasync.end (res);
    print ("\nEND\n");
    loop.quit ();
  });

  loop.run ();

  EasyZmq.Deinit ();
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]