typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
/**
+ * @typedef Ecore_Con_Event_Client_Write
+ * Used as the @p data param for the corresponding event
+ * @since 1.1
+ */
+typedef struct _Ecore_Con_Event_Client_Write Ecore_Con_Event_Client_Write;
+
+/**
+ * @typedef Ecore_Con_Event_Server_Write
+ * Used as the @p data param for the corresponding event
+ * @since 1.1
+ */
+typedef struct _Ecore_Con_Event_Server_Write Ecore_Con_Event_Server_Write;
+
+/**
* @typedef Ecore_Con_Event_Url_Data
* Used as the @p data param for the corresponding event
* @ingroup Ecore_Con_Url_Group
};
/**
+ * @struct _Ecore_Con_Event_Client_Write
+ * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_WRITE event
+ */
+struct _Ecore_Con_Event_Client_Write
+{
+ Ecore_Con_Client *client; /**< the client that connected */
+ int size; /**< the length of the data sent */
+};
+
+/**
+ * @struct _Ecore_Con_Event_Server_Write
+ * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_WRITE event
+ */
+struct _Ecore_Con_Event_Server_Write
+{
+ Ecore_Con_Server *server; /**< the server that was connected to */
+ int size; /**< the length of the data sent */
+};
+
+/**
* @struct _Ecore_Con_Event_Url_Data
* Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event
* @ingroup Ecore_Con_Url_Group
* @since 1.1
*/
EAPI extern int ECORE_CON_EVENT_SERVER_UPGRADE;
+/** A server connection has sent data to its client
+ * @since 1.1
+ */
+EAPI extern int ECORE_CON_EVENT_CLIENT_WRITE;
+/** A server connection object has sent data
+ * @since 1.1
+ */
+EAPI extern int ECORE_CON_EVENT_SERVER_WRITE;
/** A client connected to the server has sent data */
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
/** A server connection object has data */
Ecore_Con_Event_Server_Error *e);
static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
Ecore_Con_Event_Client_Error *e);
+static void _ecore_con_event_server_write_free(void *data,
+ Ecore_Con_Event_Server_Write *e);
+static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
+ Ecore_Con_Event_Client_Write *e);
static void _ecore_con_lookup_done(void *data,
Ecore_Con_Info *infos);
EAPI int ECORE_CON_EVENT_SERVER_DEL = 0;
EAPI int ECORE_CON_EVENT_CLIENT_DATA = 0;
EAPI int ECORE_CON_EVENT_SERVER_DATA = 0;
+EAPI int ECORE_CON_EVENT_CLIENT_WRITE = 0;
+EAPI int ECORE_CON_EVENT_SERVER_WRITE = 0;
EAPI int ECORE_CON_EVENT_CLIENT_ERROR = 0;
EAPI int ECORE_CON_EVENT_SERVER_ERROR = 0;
ECORE_CON_EVENT_SERVER_DEL = ecore_event_type_new();
ECORE_CON_EVENT_CLIENT_DATA = ecore_event_type_new();
ECORE_CON_EVENT_SERVER_DATA = ecore_event_type_new();
+ ECORE_CON_EVENT_CLIENT_WRITE = ecore_event_type_new();
+ ECORE_CON_EVENT_SERVER_WRITE = ecore_event_type_new();
ECORE_CON_EVENT_CLIENT_ERROR = ecore_event_type_new();
ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new();
}
void
+ecore_con_event_server_write(Ecore_Con_Server *svr, int num)
+{
+ Ecore_Con_Event_Server_Write *e;
+
+ e = malloc(sizeof(Ecore_Con_Event_Server_Write));
+ EINA_SAFETY_ON_NULL_RETURN(e);
+
+ svr->event_count++;
+ e->server = svr;
+ e->size = num;
+ ecore_event_add(ECORE_CON_EVENT_SERVER_WRITE, e,
+ (Ecore_End_Cb)_ecore_con_event_server_write_free, NULL);
+
+}
+
+void
ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num, Eina_Bool duplicate)
{
Ecore_Con_Event_Server_Data *e;
}
void
+ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
+{
+ Ecore_Con_Event_Client_Write *e;
+ e = malloc(sizeof(Ecore_Con_Event_Client_Write));
+ EINA_SAFETY_ON_NULL_RETURN(e);
+
+ cl->host_server->event_count++;
+ cl->event_count++;
+ e->client = cl;
+ e->size = num;
+ ecore_event_add(ECORE_CON_EVENT_CLIENT_WRITE, e,
+ (Ecore_End_Cb)_ecore_con_event_client_write_free, cl->host_server);
+}
+
+void
ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate)
{
Ecore_Con_Event_Client_Data *e;
return;
}
+ if (count) ecore_con_event_server_write(svr, count);
svr->write_buf_offset += count;
if (svr->write_buf_offset >= eina_binbuf_length_get(svr->buf))
{
return;
}
+ if (count) ecore_con_event_client_write(cl, count);
cl->buf_offset += count;
if (cl->buf_offset >= eina_binbuf_length_get(cl->buf))
{
}
static void
+_ecore_con_event_client_write_free(Ecore_Con_Server *svr,
+ Ecore_Con_Event_Client_Write *e)
+{
+ e->client->event_count--;
+ e->client->host_server->event_count--;
+
+ if (((e->client->event_count <= 0) && (e->client->delete_me)) ||
+ ((e->client->host_server &&
+ ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
+ (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
+ ecore_con_client_del(e->client);
+ if ((svr->event_count <= 0) && (svr->delete_me))
+ _ecore_con_server_free(svr);
+
+ free(e);
+}
+
+static void
_ecore_con_event_client_data_free(Ecore_Con_Server *svr,
void *ev)
{
}
static void
+_ecore_con_event_server_write_free(void *data __UNUSED__,
+ Ecore_Con_Event_Server_Write *e)
+{
+ e->server->event_count--;
+
+ if ((e->server->event_count <= 0) && (e->server->delete_me))
+ _ecore_con_server_free(e->server);
+
+ free(e);
+}
+
+static void
_ecore_con_event_server_data_free(void *data __UNUSED__,
void *ev)
{