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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 146 - (hide annotations) (download) (as text)
Fri Jun 25 12:00:25 2004 UTC (19 years, 10 months ago) by capela
File MIME type: text/x-c++hdr
File size: 3823 byte(s)
* Major changes to server event protocol interface
  on attempt to comply with draft-protocol v.11.

1 capela 62 // server.h
2     //
3     /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.
6    
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     You should have received a copy of the GNU Lesser General Public
18     License along with this library; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20    
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     LSCP_SERVER_THREAD = 0,
40     LSCP_SERVER_SELECT = 1
41    
42     } lscp_server_mode_t;
43    
44    
45     /** Connection mode notification. */
46     typedef enum _lscp_connect_mode_t
47     {
48     LSCP_CONNECT_OPEN = 0,
49     LSCP_CONNECT_CLOSE = 1
50    
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     struct _lscp_server_t *server;
63     lscp_socket_agent_t client;
64 capela 146 lscp_event_t events;
65 capela 62 struct _lscp_connect_t *prev;
66     struct _lscp_connect_t *next;
67    
68     } lscp_connect_t;
69    
70     /** Client connection list struct. */
71     typedef struct _lscp_connect_list_t
72     {
73     lscp_connect_t *first;
74     lscp_connect_t *last;
75     unsigned int count;
76     lscp_mutex_t mutex;
77    
78     } lscp_connect_list_t;
79    
80     /** Server callback procedure prototype. */
81     typedef lscp_status_t (*lscp_server_proc_t)
82     (
83     lscp_connect_t *pConnect,
84     const char *pchBuffer,
85     int cchBuffer,
86     void *pvData
87     );
88    
89     /** Server descriptor struct. */
90     typedef struct _lscp_server_t
91     {
92     lscp_server_mode_t mode;
93     lscp_connect_list_t connects;
94     lscp_server_proc_t pfnCallback;
95     void *pvData;
96 capela 146 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