Renamed some functions and callbacks for consistency
This commit is contained in:
parent
515825fa53
commit
2ee7645798
|
@ -73,8 +73,13 @@ struct _AppTransportPluginDefinition
|
||||||
AppTransportPlugin * (*init)(AppTransportPluginHelper * helper,
|
AppTransportPlugin * (*init)(AppTransportPluginHelper * helper,
|
||||||
AppTransportMode mode, char const * name);
|
AppTransportMode mode, char const * name);
|
||||||
void (*destroy)(AppTransportPlugin * transport);
|
void (*destroy)(AppTransportPlugin * transport);
|
||||||
int (*send)(AppTransportPlugin * transport, AppMessage * message);
|
|
||||||
|
/* ATM_CLIENT */
|
||||||
int (*client_send)(AppTransportPlugin * transport,
|
int (*client_send)(AppTransportPlugin * transport,
|
||||||
|
AppMessage * message);
|
||||||
|
|
||||||
|
/* ATM_SERVER */
|
||||||
|
int (*server_send)(AppTransportPlugin * transport,
|
||||||
AppTransportClient * client, AppMessage * message);
|
AppTransportClient * client, AppMessage * message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -133,22 +133,7 @@ void apptransport_delete(AppTransport * transport)
|
||||||
|
|
||||||
/* useful */
|
/* useful */
|
||||||
/* apptransport_client_send */
|
/* apptransport_client_send */
|
||||||
int apptransport_client_send(AppTransport * transport,
|
int apptransport_client_send(AppTransport * transport, AppMessage * message,
|
||||||
AppTransportClient * client, AppMessage * message)
|
|
||||||
{
|
|
||||||
if(transport->mode != ATM_SERVER)
|
|
||||||
return -error_set_code(1, "%s",
|
|
||||||
"Only servers can reply to clients");
|
|
||||||
if(transport->definition->client_send == NULL)
|
|
||||||
return -error_set_code(1, "%s",
|
|
||||||
"This transport does not support replies");
|
|
||||||
return transport->definition->client_send(transport->tplugin, client,
|
|
||||||
message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* apptransport_send */
|
|
||||||
int apptransport_send(AppTransport * transport, AppMessage * message,
|
|
||||||
int acknowledge)
|
int acknowledge)
|
||||||
{
|
{
|
||||||
if(transport->mode == ATM_CLIENT
|
if(transport->mode == ATM_CLIENT
|
||||||
|
@ -156,7 +141,22 @@ int apptransport_send(AppTransport * transport, AppMessage * message,
|
||||||
&& acknowledge != 0)
|
&& acknowledge != 0)
|
||||||
/* FIXME will wrap around after 2^32-1 acknowledgements */
|
/* FIXME will wrap around after 2^32-1 acknowledgements */
|
||||||
appmessage_set_id(message, ++transport->id);
|
appmessage_set_id(message, ++transport->id);
|
||||||
return transport->definition->send(transport->tplugin, message);
|
return transport->definition->client_send(transport->tplugin, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* apptransport_server_send */
|
||||||
|
int apptransport_server_send(AppTransport * transport,
|
||||||
|
AppTransportClient * client, AppMessage * message)
|
||||||
|
{
|
||||||
|
if(transport->mode != ATM_SERVER)
|
||||||
|
return -error_set_code(1, "%s",
|
||||||
|
"Only servers can reply to clients");
|
||||||
|
if(transport->definition->server_send == NULL)
|
||||||
|
return -error_set_code(1, "%s",
|
||||||
|
"This transport does not support replies");
|
||||||
|
return transport->definition->server_send(transport->tplugin, client,
|
||||||
|
message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ static int _apptransport_helper_client_receive(AppTransport * transport,
|
||||||
/* XXX we can ignore errors */
|
/* XXX we can ignore errors */
|
||||||
if((message = appmessage_new_acknowledgement(id)) != NULL)
|
if((message = appmessage_new_acknowledgement(id)) != NULL)
|
||||||
{
|
{
|
||||||
apptransport_client_send(transport, client, message);
|
apptransport_server_send(transport, client, message);
|
||||||
appmessage_delete(message);
|
appmessage_delete(message);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -39,10 +39,12 @@ AppTransport * apptransport_new(AppTransportMode mode,
|
||||||
void apptransport_delete(AppTransport * transport);
|
void apptransport_delete(AppTransport * transport);
|
||||||
|
|
||||||
/* useful */
|
/* useful */
|
||||||
int apptransport_client_send(AppTransport * transport,
|
/* ATM_CLIENT */
|
||||||
AppTransportClient * client, AppMessage * message);
|
int apptransport_client_send(AppTransport * transport, AppMessage * message,
|
||||||
|
|
||||||
int apptransport_send(AppTransport * transport, AppMessage * message,
|
|
||||||
int acknowledge);
|
int acknowledge);
|
||||||
|
|
||||||
|
/* ATM_SERVER */
|
||||||
|
int apptransport_server_send(AppTransport * transport,
|
||||||
|
AppTransportClient * client, AppMessage * message);
|
||||||
|
|
||||||
#endif /* !LIBAPP_APPTRANSPORT_H */
|
#endif /* !LIBAPP_APPTRANSPORT_H */
|
||||||
|
|
|
@ -207,7 +207,7 @@ static int _transport_callback_idle(void * data)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
transport->plugind->send(transport->client, transport->message);
|
transport->plugind->client_send(transport->client, transport->message);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user