YAMI4Industry
agent.h
Go to the documentation of this file.
1 /* Copyright Inspirel Sp. z o.o. 2013-2015.
2  * This file is part of YAMI4.
3  *
4  * YAMI4 is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * YAMI4 is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef YAMI4INDUSTRY_AGENT_H
19 #define YAMI4INDUSTRY_AGENT_H
20 
21 #include "callbacks.h"
22 #include "channel.h"
23 #include "common.h"
24 #include "limits.h"
25 #include "options.h"
26 
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif /* __cplusplus */
34 
44 struct yami_agent
45 {
48 
51 
56 
58 
61 
63 };
64 
77 void yami_init(struct yami_agent * self);
78 
94 void yami_init_with_user_array(struct yami_agent * self,
95  struct yami_channel channels_array[], size_t channels_array_size);
96 
109 void yami_init_with_options(struct yami_agent * self,
110  const struct yami_options * options);
111 
127 void yami_init_with_options_ua(struct yami_agent * self,
128  const struct yami_options * options,
129  struct yami_channel channels_array[], size_t channels_array_size);
130 
140 enum yami_result yami_clean(struct yami_agent * self);
141 
152 void yami_set_io_error_callback(struct yami_agent * self,
153  yami_io_error_function io_error_callback);
154 
169 void yami_set_raw_message_callback(struct yami_agent * self,
170  yami_raw_message_function raw_message_callback);
171 
187 void yami_set_message_callback(struct yami_agent * self,
188  yami_message_function message_callback);
189 
204 void yami_set_connection_callback(struct yami_agent * self,
205  yami_connection_event_function connection_callback);
206 
219 enum yami_result yami_set_listener(struct yami_agent * self,
220  const char target[]);
221 
234 enum yami_result yami_open_connection(struct yami_agent * self,
235  const char target[]);
236 
249 enum yami_result yami_close_connection(struct yami_agent * self,
250  const char target[]);
251 
263 enum yami_result yami_is_output_channel_busy(const struct yami_agent * self,
264  const char target[], int32_t * out_busy);
265 
287 enum yami_result yami_post_raw_message(struct yami_agent * self,
288  const char target[],
289  const uint8_t header[], size_t header_size,
290  const uint8_t body[], size_t body_size);
291 
313 enum yami_result yami_post_message(struct yami_agent * self,
314  const char target[], const char object_name[], const char message_name[],
315  const uint8_t body[], size_t body_size,
316  int64_t * out_message_id);
317 
338 enum yami_result yami_post_reply(struct yami_agent * self,
339  const char target[], int64_t message_id,
340  const uint8_t body[], size_t body_size);
341 
362 enum yami_result yami_post_reject(struct yami_agent * self,
363  const char target[], int64_t message_id, const char reason[]);
364 
377 enum yami_result yami_do_some_work(struct yami_agent * self,
378  size_t timeout);
379 
380 #ifdef __cplusplus
381 }
382 #endif /* __cplusplus */
383 
384 #endif /* YAMI4INDUSTRY_AGENT_H */
int32_t listening_socket_
Definition: agent.h:46
struct yami_channel * channels_array_
Definition: agent.h:59
void(* yami_io_error_function)(int32_t error_code, const char description[])
Definition: callbacks.h:81
Definition: options.h:30
void(* yami_message_function)(const char target[], enum yami_message_type message_type, const char object_name[], const char message_name[], const char exception_msg[], int64_t message_id, const uint8_t body[], size_t body_size)
Definition: callbacks.h:69
void yami_init_with_options(struct yami_agent *self, const struct yami_options *options)
Initializer.
Definition: agent.c:118
enum yami_result yami_post_reply(struct yami_agent *self, const char target[], int64_t message_id, const uint8_t body[], size_t body_size)
Posts the high-level message reply.
Definition: agent.c:378
void yami_set_connection_callback(struct yami_agent *self, yami_connection_event_function connection_callback)
Sets the connection event callback.
Definition: agent.c:195
struct yami_channel channels_[MAX_NUMBER_OF_CHANNELS]
Definition: agent.h:62
yami_connection_event_function connection_callback_
Definition: agent.h:55
yami_result
Definition: common.h:28
enum yami_result yami_close_connection(struct yami_agent *self, const char target[])
Closes communication channel.
Definition: agent.c:276
void(* yami_connection_event_function)(enum yami_connection_event event, const char target[])
Definition: callbacks.h:98
void yami_init_with_user_array(struct yami_agent *self, struct yami_channel channels_array[], size_t channels_array_size)
Initializer.
Definition: agent.c:110
int64_t last_message_id_
Definition: agent.h:50
enum yami_protocol listening_protocol_
Definition: agent.h:47
Message broker.
Definition: agent.h:44
void yami_set_message_callback(struct yami_agent *self, yami_message_function message_callback)
Sets the high-level message callback.
Definition: agent.c:189
enum yami_result yami_post_message(struct yami_agent *self, const char target[], const char object_name[], const char message_name[], const uint8_t body[], size_t body_size, int64_t *out_message_id)
Posts the high-level message.
Definition: agent.c:351
void yami_init(struct yami_agent *self)
Initializer.
Definition: agent.c:103
enum yami_result yami_clean(struct yami_agent *self)
Destructor.
Definition: agent.c:135
enum yami_result yami_set_listener(struct yami_agent *self, const char target[])
Sets the optional listener.
Definition: agent.c:201
void yami_set_raw_message_callback(struct yami_agent *self, yami_raw_message_function raw_message_callback)
Sets the raw message callback.
Definition: agent.c:183
#define MAX_NUMBER_OF_CHANNELS
Definition: limits.h:26
void yami_set_io_error_callback(struct yami_agent *self, yami_io_error_function io_error_callback)
Sets the error logger callback function.
Definition: agent.c:177
yami_message_function message_callback_
Definition: agent.h:53
enum yami_result yami_do_some_work(struct yami_agent *self, size_t timeout)
Performs some unit of network-related activity.
Definition: agent.c:641
Definition: channel.h:36
yami_raw_message_function raw_message_callback_
Definition: agent.h:52
yami_io_error_function io_error_callback_
Definition: agent.h:54
struct yami_options options_
Definition: agent.h:57
void(* yami_raw_message_function)(const char target[], const uint8_t header[], size_t header_size, const uint8_t body[], size_t body_size)
Definition: callbacks.h:39
enum yami_result yami_post_reject(struct yami_agent *self, const char target[], int64_t message_id, const char reason[])
Posts the high-level message rejection.
Definition: agent.c:400
size_t channels_array_size_
Definition: agent.h:60
yami_protocol
Definition: channel.h:34
uint32_t last_core_message_id_
Definition: agent.h:49
void yami_init_with_options_ua(struct yami_agent *self, const struct yami_options *options, struct yami_channel channels_array[], size_t channels_array_size)
Initializer.
Definition: agent.c:126
enum yami_result yami_is_output_channel_busy(const struct yami_agent *self, const char target[], int32_t *out_busy)
Checks if there is space in the output channel.
Definition: agent.c:311
enum yami_result yami_open_connection(struct yami_agent *self, const char target[])
Creates (opens) outgoing communication channel.
Definition: agent.c:265
enum yami_result yami_post_raw_message(struct yami_agent *self, const char target[], const uint8_t header[], size_t header_size, const uint8_t body[], size_t body_size)
Posts the raw message.
Definition: agent.c:328