Index: plugins/universal/tic-tac-toe.c
===================================================================
--- plugins/universal/tic-tac-toe.c	(revision 5569)
+++ plugins/universal/tic-tac-toe.c	(revision 5579)
@@ -24,5 +24,5 @@
  */
 
-#include <roard/include/roard.h>
+#include <roaraudio.h>
 
 #define _FREE     ' '
@@ -89,4 +89,14 @@
 };
 
+static inline int __movein(struct roar_buffer ** buf, struct roar_buffer ** next) {
+ if ( *buf == NULL ) {
+  *buf = *next;
+  *next = NULL;
+  return 0;
+ } else {
+  return roar_buffer_moveinto(*buf, next);
+ }
+}
+
 static void new_game(game_state * state) {
  memset(state, _FREE, sizeof(game_state));
@@ -211,5 +221,5 @@
 }
 
-static void draw_help(int client) {
+static void draw_help(struct roar_buffer ** obuffer) {
  struct roar_buffer * buf;
  ssize_t len = 0;
@@ -225,11 +235,10 @@
  if ( roar_buffer_set_len(buf, len) == -1 ) {
   roar_buffer_free(buf);
-  clients_delete(client);
- }
-
- clients_add_output(client, &buf);
-}
-
-static void draw_game(int client, game_state * state, const char * info) {
+ }
+
+ __movein(obuffer, &buf);
+}
+
+static void draw_game(game_state * state, const char * info, struct roar_buffer ** obuffer) {
  struct roar_buffer * buf;
  ssize_t len = 0;
@@ -249,18 +258,13 @@
  if ( roar_buffer_set_len(buf, len) == -1 ) {
   roar_buffer_free(buf);
-  clients_delete(client);
- }
-
- clients_add_output(client, &buf);
-}
-
-int new_client(int client, struct roar_vio_calls * vio, struct roard_listen * lsock) {
- struct roar_client_server * cs;
+ }
+
+ __movein(obuffer, &buf);
+}
+
+static int _set_proto(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * para, ssize_t paralen) {
  game_state * state;
 
- (void)vio, (void)lsock;
-
- if ( clients_get_server(client, &cs) == -1 )
-  return -1;
+ (void)client, (void)vio, (void)obuffer, (void)para, (void)paralen;
 
  state = roar_mm_malloc(sizeof(game_state));
@@ -270,7 +274,7 @@
  new_game(state);
 
- cs->protoinst = state;
-
- draw_game(client, state, MSG__YOUR_TURN);
+ *userdata = state;
+
+ draw_game(state, MSG__YOUR_TURN, obuffer);
  return 0;
 }
@@ -307,6 +311,5 @@
 }
 
-static int check_client(int client, struct roar_vio_calls * vio) {
- struct roar_client_server * cs;
+static int _handle(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * para, ssize_t paralen) {
  char buf[32];
  ssize_t len;
@@ -317,24 +320,21 @@
  char c;
 
+ (void)client, (void)obuffer, (void)para, (void)paralen;
+
  ROAR_DBG("check_client(client=%i, vio=%p) = ?", client, vio);
 
- if ( clients_get_server(client, &cs) == -1 )
+ len = roar_vio_read(vio, buf, sizeof(buf));
+
+ if ( len < 1 ) {
   return -1;
-
- len = roar_vio_read(vio, buf, sizeof(buf));
-
- if ( len < 1 ) {
-  clients_delete(client);
-  return -1;
- }
-
- if ( check_won(cs->protoinst) ) {
+ }
+
+ if ( check_won(*userdata) ) {
   for (i = 0; i < len; i++) {
    if ( map_input(buf[i]) == 'q' ) {
-    clients_delete(client);
     return -1;
    } else {
-    new_game(cs->protoinst);
-    draw_game(client, cs->protoinst, MSG__YOUR_TURN);
+    new_game(*userdata);
+    draw_game(*userdata, MSG__YOUR_TURN, obuffer);
     return 0;
    }
@@ -346,25 +346,24 @@
   switch (c) {
    case 'q':
-     clients_delete(client);
      return -1;
     break;
    case 'n':
-     new_game(cs->protoinst);
-     draw_game(client, cs->protoinst, MSG__YOUR_TURN);
+     new_game(*userdata);
+     draw_game(*userdata, MSG__YOUR_TURN, obuffer);
      return 0;
     break;
    case 'H':
-     draw_help(client);
+     draw_help(obuffer);
      return 0;
     break;
    case 'e':
-     draw_game(client, cs->protoinst, MSG__YOUR_TURN);
+     draw_game(*userdata, MSG__YOUR_TURN, obuffer);
      return 0;
     break;
    case '0': case '1': case '2': case '3': case '4':
    case '5': case '6': case '7': case '8':
-     if ( try_put(cs->protoinst, c - '0', _PLAYER) == -1 ) {
+     if ( try_put(*userdata, c - '0', _PLAYER) == -1 ) {
       msg = MSG__CANNOT_PUT_HERE;
-      draw_game(client, cs->protoinst, msg);
+      draw_game(*userdata, msg, obuffer);
       return 0;
      } else {
@@ -377,9 +376,9 @@
  }
 
- won = check_won(cs->protoinst);
+ won = check_won(*userdata);
 
  if ( !won && player_move != -1 ) {
-  auto_move(cs->protoinst, player_move);
-  won = check_won(cs->protoinst);
+  auto_move(*userdata, player_move);
+  won = check_won(*userdata);
  }
 
@@ -390,5 +389,5 @@
  }
 
- draw_game(client, cs->protoinst, msg);
+ draw_game(*userdata, msg, obuffer);
 
  ROAR_DBG("check_client(client=%i, vio=%p) = 0", client, vio);
@@ -397,13 +396,23 @@
 
 
-static struct roard_proto proto[1] = {
- {ROAR_PROTO_GAME, ROAR_SUBSYS_NONE, "Simple Tic-Tac-Toe game", NULL, new_client, NULL, check_client, NULL, NULL}
+static const struct roar_dl_proto proto = {
+ .proto = ROAR_PROTO_GAME,
+ .description = "Simple Tic-Tac-Toe game",
+ .flags = ROAR_DL_PROTO_FLAGS_NONE,
+ .set_proto = _set_proto,
+ .unset_proto = NULL,
+ .handle = _handle,
+ .flush = NULL,
+ .flushed = NULL,
+ .status = NULL
 };
 
-ROARD_DL_REG_PROTO(proto)
+static int __reg_proto(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) {
+ (void)para, (void)lib;
+ ROAR_DL_PLUGIN_REG_FN(ROAR_DL_PROTO_SUBTYPE, proto, ROAR_DL_PROTO_VERSION);
+ return 0;
+}
 
 ROAR_DL_PLUGIN_START(protocol_tic_tac_toe) {
- ROARD_DL_CHECK_VERSIONS();
-
  ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-tic-tac-toe", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO);
  ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING);
@@ -412,5 +421,5 @@
  ROAR_DL_PLUGIN_META_DESC("Implementation of a the well known game Tic-Tac-Toe");
 
- ROARD_DL_REGFN_PROTO();
+ ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto);
 } ROAR_DL_PLUGIN_END
 
