/[svn]/liblscp/trunk/examples/server.h
ViewVC logotype

Annotation of /liblscp/trunk/examples/server.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3866 - (hide annotations) (download) (as text)
Sat Mar 27 12:17:51 2021 UTC (3 years, 1 month ago) by capela
File MIME type: text/x-c++hdr
File size: 3761 byte(s)
* Switching to CMake build system as for packaging default.
1 capela 62 // server.h
2     //
3     /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API
5 capela 3866 Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved.
6 capela 62
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public
9     License as published by the Free Software Foundation; either
10     version 2.1 of the License, or (at your option) any later version.
11    
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15     Lesser General Public License for more details.
16    
17 capela 921 You should have received a copy of the GNU General Public License along
18     with this program; if not, write to the Free Software Foundation, Inc.,
19     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 capela 62
21     *****************************************************************************/
22    
23     #ifndef __LSCP_SERVER_H
24     #define __LSCP_SERVER_H
25    
26     #include "lscp/socket.h"
27 capela 146 #include "lscp/event.h"
28 capela 62
29     #if defined(__cplusplus)
30     extern "C" {
31     #endif
32    
33     //-------------------------------------------------------------------------
34     // Server socket modes.
35    
36     /** Server thread model. */
37     typedef enum _lscp_server_mode_t
38     {
39 capela 963 LSCP_SERVER_THREAD = 0,
40     LSCP_SERVER_SELECT = 1
41 capela 62
42     } lscp_server_mode_t;
43    
44    
45     /** Connection mode notification. */
46     typedef enum _lscp_connect_mode_t
47     {
48 capela 963 LSCP_CONNECT_OPEN = 0,
49     LSCP_CONNECT_CLOSE = 1
50 capela 62
51     } lscp_connect_mode_t;
52    
53    
54     //-------------------------------------------------------------------------
55     // Server socket structures.
56    
57     struct _lscp_server_t;
58    
59     /** Client connection descriptor struct. */
60     typedef struct _lscp_connect_t
61     {
62 capela 963 struct _lscp_server_t *server;
63     lscp_socket_agent_t client;
64     lscp_event_t events;
65     struct _lscp_connect_t *prev;
66     struct _lscp_connect_t *next;
67 capela 62
68     } lscp_connect_t;
69    
70     /** Client connection list struct. */
71     typedef struct _lscp_connect_list_t
72     {
73 capela 963 lscp_connect_t *first;
74     lscp_connect_t *last;
75     unsigned int count;
76     lscp_mutex_t mutex;
77 capela 62
78     } lscp_connect_list_t;
79    
80     /** Server callback procedure prototype. */
81     typedef lscp_status_t (*lscp_server_proc_t)
82     (
83 capela 963 lscp_connect_t *pConnect,
84     const char *pchBuffer,
85     int cchBuffer,
86     void *pvData
87 capela 62 );
88    
89     /** Server descriptor struct. */
90     typedef struct _lscp_server_t
91     {
92 capela 963 lscp_server_mode_t mode;
93     lscp_connect_list_t connects;
94     lscp_server_proc_t pfnCallback;
95     void *pvData;
96     lscp_socket_agent_t agent;
97 capela 62
98     } lscp_server_t;
99    
100    
101     //-------------------------------------------------------------------------
102     // Server versioning teller fuunctions.
103    
104     const char * lscp_server_package (void);
105     const char * lscp_server_version (void);
106     const char * lscp_server_build (void);
107    
108    
109     //-------------------------------------------------------------------------
110     // Server socket functions.
111    
112     lscp_server_t * lscp_server_create (int iPort, lscp_server_proc_t pfnCallback, void *pvData);
113     lscp_server_t * lscp_server_create_ex (int iPort, lscp_server_proc_t pfnCallback, void *pvData, lscp_server_mode_t mode);
114     lscp_status_t lscp_server_join (lscp_server_t *pServer);
115     lscp_status_t lscp_server_destroy (lscp_server_t *pServer);
116    
117 capela 146 lscp_status_t lscp_server_broadcast (lscp_server_t *pServer, lscp_event_t event, const char *pchData, int cchData);
118 capela 62
119     lscp_status_t lscp_server_result (lscp_connect_t *pConnect, const char *pchBuffer, int cchBuffer);
120    
121 capela 146 lscp_status_t lscp_server_subscribe (lscp_connect_t *pConnect, lscp_event_t event);
122     lscp_status_t lscp_server_unsubscribe (lscp_connect_t *pConnect, lscp_event_t event);
123 capela 62
124    
125     #if defined(__cplusplus)
126     }
127     #endif
128    
129     #endif // __LSCP_SERVER_H
130    
131     // end of server.h

  ViewVC Help
Powered by ViewVC