source: neercs/trunk/src/mini-client.c @ 4379

Last change on this file since 4379 was 4379, checked in by Sam Hocevar, 10 years ago

Networking tests. Doesn't work yet.

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/*
2 *  neercs        console-based window manager
3 *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
4 *                2008-2010 Jean-Yves Lamoureux <jylam@lnxscene.org>
5 *                2008-2010 Pascal Terjan <pterjan@linuxfr.org>
6 *                All Rights Reserved
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#if defined HAVE_CONFIG_H
16#   include "config.h"
17#endif
18
19#include "mini-neercs.h"
20#include "mini-socket.h"
21
22#include <caca.h>
23
24static caca_display_t *dp;
25static caca_canvas_t *cv;
26static nrx_socket_t *insock, *outsock;
27
28void client_init(void)
29{
30    int i, usec = 1000;
31
32    cv = caca_create_canvas(0, 0);
33    dp = caca_create_display(cv);
34    caca_set_display_title(dp, "Press Esc to quit");
35
36    for (i = 0; i < 10; i++)
37    {
38        outsock = socket_open("/tmp/neercs.sock", 0);
39        if (outsock)
40            break;
41        usleep(usec);
42        usec += usec;
43    }
44
45    insock = socket_open("/tmp/neercs.sock.client", 1);
46
47    socket_puts(outsock, "CONNECT /tmp/neercs.sock.client");
48}
49
50int client_step(void)
51{
52    caca_event_t ev;
53    if(caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, 1000)
54        && caca_get_event_key_ch(&ev) == CACA_KEY_ESCAPE)
55        return 0;
56    return 1;
57}
58
59void client_fini(void)
60{
61    caca_free_display(dp);
62    caca_free_canvas(cv);
63}
64
Note: See TracBrowser for help on using the repository browser.