/** * eventc_light_connection_close: * @connection: an #EventcLightConnection * * Closes the connection. * * Returns: 0 if the connection was successfully closed, a negative %errno value otherwise */ EVENTD_EXPORT gint eventc_light_connection_close(EventcLightConnection *self) { g_return_val_if_fail(self != NULL, -EFAULT); gint error = 0; if ( eventc_light_connection_is_connected(self, &error) ) _eventc_light_connection_send_message(self, eventd_protocol_generate_bye(self->protocol, NULL)); else if ( error != 0 ) return error; _eventc_light_connection_close_internal(self); return 0; }
static void _test_evp_generate_bye(gpointer fixture, gconstpointer user_data) { GeneratorData *data = fixture; gboolean with_message = GPOINTER_TO_INT(user_data); const gchar *expected; const gchar *bye_message = NULL; gchar *message; if ( with_message ) { bye_message = "test"; expected = "BYE test\n"; } else expected = "BYE\n"; message = eventd_protocol_generate_bye(data->protocol, bye_message); g_assert_cmpstr(message, ==, expected); g_free(message); }