Commit 1f97684f authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

Some new propositions in libovccclient about the API...

parent 9359ce6a
......@@ -6,7 +6,8 @@ libovccclient_la_CPPFLAGS = -DG_LOG_DOMAIN=\"LibOVCCClient\"
libovccclient_la_VALAFLAGS = $(VALAFLAGS) --library=ovccclient --header=ovccclient.h \
--vapidir=.
libovccclient_la_SOURCES = client.vala \
server.vala
server.vala \
game.vala
ovccinclude_HEADERS = ovccclient.h
test_LDADD = libovccclient.la -lpthread
......
namespace OVCCClient
{
public errordomain ClientError
{
ALREADY_BOUND,
FAILED
}
public class Client : Object
{
public Server server {get; private set; default = null;}
public Player player {get; construct;}
public Game game {get; private set; default = null;}
public Client (Player p)
{
player = p;
}
public bool bind_to (Server s)
throws ClientError
{
if (server != null)
{
throw new ALREADY_BOUND ("This client is already bound to a server");
}
server = s;
server.connect (player);
}
public bool leave ()
{
/* destroy server */
server = null;
}
}
}
namespace OVCCClient {
public class Game : OVCC.Game
{
/* network wrapper around OVCC Game */
}
}
......@@ -3,9 +3,11 @@ namespace OVCCClient
{
public errordomain ServerError
{
COMMUNICATION_FAILED,
INVALID_NICKNAME,
NICKNAME_IN_USE,
MISSING_AUTHENTICATION,
NO_OPEN_TABLE,
FAILED
}
......@@ -13,7 +15,9 @@ namespace OVCCClient
public enum TablesFilter
{
ALL,
OPEN
OPEN,
PEOPLE_WAITING,
ASKING_FOR_PEOPLE
}
public class Server : Object
......@@ -41,13 +45,20 @@ namespace OVCCClient
{
try {
connexion = socket.connect (host, port, null);
} /* ... */
} catch {} /* ... */
}
public List<OVCC.Game> enumerate_tables (TablesFilter filter)
{
}
/* join a table, index -1 means any open table
* The index is typically within the list returned by enumerate_tables() */
public Game join_table (int index)
throws ServerError
{
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment