Exemplo n.º 1
0
int
client_data (void *data,
	     int ev_type,
	     Ecore_Con_Event_Client_Data *ev) {
  printf("Client sent data!  Replying...");
  ecore_con_client_send(ev->client, msg, strlen(msg));
  printf("done!  Data was:\n");
  printf("  %*s\n", ev->size, (char *)ev->data);
  return 0;
}
Exemplo n.º 2
0
Eina_Bool
_add(void *data, int type, Ecore_Con_Event_Client_Add *ev)
{
   printf("Client with ip %s connected!\n", ecore_con_client_ip_get(ev->client));
   ecore_con_client_send(ev->client, "hello!", 6);
//   ecore_con_client_flush(ev->client);
   ecore_con_client_timeout_set(ev->client, 5);

   return ECORE_CALLBACK_RENEW;
}
Exemplo n.º 3
0
static Eina_Bool
_my_hack2(void *data)
{
   Elsa_Event eev;
   void *enc;
   int size;
   eev.type = ELSA_EVENT_ACTIONS;
   eev.event.actions.actions = elsa_action_get();
   enc = elsa_event_encode(&eev, &size);
   ecore_con_client_send(data, enc, size);
//   ecore_con_client_flush(ev->client);
   return ECORE_CALLBACK_CANCEL;
}
Exemplo n.º 4
0
static Eina_Bool
_my_hack(void *data)
{
   Elsa_Event eev;
   void *enc;
   int size;

   eev.type = ELSA_EVENT_XSESSIONS;
   if (elsa_config->xsessions)
     {
        eev.event.xsessions.xsessions = elsa_session_list_get();
        enc = elsa_event_encode(&eev, &size);
        ecore_con_client_send(data, enc, size);
     }
   ecore_timer_add(0.5, _my_hack2, data);
//   ecore_con_client_flush(ev->client);
   return ECORE_CALLBACK_CANCEL;
}
Exemplo n.º 5
0
Eina_Bool
azy_events_connection_kill(void       *conn,
                           Eina_Bool   server_client,
                           const char *msg)
{
   DBG("(conn=%p, server_client=%i, msg='%s')", conn, server_client, msg);
   if (msg)
     {
        if (server_client)
          ecore_con_client_send(conn, msg, strlen(msg));
        else
          ecore_con_server_send(conn, msg, strlen(msg));
     }

   if (server_client)
     ecore_con_client_del(conn);
   else
     ecore_con_server_del(conn);
   return ECORE_CALLBACK_RENEW;
}
Exemplo n.º 6
0
int
epsilon_ipc_client_send(Ecore_Con_Client *cl, Epsilon_Message *msg)
{
	return ecore_con_client_send(cl, msg,
			sizeof(Epsilon_Message) + msg->bufsize);
}
Exemplo n.º 7
0
/**
 * @brief Send data to a client
 *
 * This function is used to queue arbitrary data to send to a client through its module.  It will automatically
 * generate all http header strings from @p net (if provided) including the content-length (based on @p data).
 * @param module The client's #Azy_Server_Module object (NOT NULL)
 * @param net An #Azy_Net object containing http information to use
 * @param data The data to send
 * @return EINA_TRUE on success, else EINA_FALSE
 */
Eina_Bool
azy_server_module_send(Azy_Server_Module *module,
                       Azy_Net *net,
                       const Azy_Net_Data *data)
{
   Eina_Strbuf *header;
   char chunk_size[20];
   Eina_Binbuf *chunk_data;
   Eina_Bool nullify = EINA_FALSE;

   if (!AZY_MAGIC_CHECK(module, AZY_MAGIC_SERVER_MODULE))
     {
        AZY_MAGIC_FAIL(module, AZY_MAGIC_SERVER_MODULE);
        return EINA_FALSE;
     }

   if (net)
     {
        if (!module->client->current)
          {
             module->client->current = net;
             nullify = EINA_TRUE;
          }

        if (net->headers_sent)
          goto post_header;

        Eina_Bool s;
        if ((data) && (net->http.transfer_encoding != AZY_NET_TRANSFER_ENCODING_CHUNKED))
          azy_net_content_length_set(net, data->size);
        if (!net->http.res.http_code)
          azy_net_code_set(net, 200);  /* OK */
        azy_net_type_set(net, AZY_NET_TYPE_RESPONSE);
        EINA_SAFETY_ON_TRUE_RETURN_VAL(!(header = azy_net_header_create(net)), EINA_FALSE);
        EINA_SAFETY_ON_NULL_RETURN_VAL(module->client->current->conn, EINA_FALSE);
        s = !!ecore_con_client_send(module->client->current->conn, eina_strbuf_string_get(header), eina_strbuf_length_get(header));
        eina_strbuf_free(header);
        if (!s)
          {
             ERR("Could not queue header for sending!");
             return EINA_FALSE;
          }
        net->headers_sent = EINA_TRUE;
     }

post_header:

   if ((!net) || (net->http.transfer_encoding != AZY_NET_TRANSFER_ENCODING_CHUNKED))
     {
        if (!data || !data->data) return EINA_TRUE;

        EINA_SAFETY_ON_NULL_RETURN_VAL(module->client->current->conn, EINA_FALSE);
        EINA_SAFETY_ON_TRUE_RETURN_VAL(!ecore_con_client_send(module->client->current->conn, data->data, data->size), EINA_FALSE);
        goto post_send;
     }

   if (!data || !data->data)
     {
        EINA_SAFETY_ON_NULL_RETURN_VAL(module->client->current->conn, EINA_FALSE);
        EINA_SAFETY_ON_TRUE_RETURN_VAL(!ecore_con_client_send(module->client->current->conn, "0\r\n\r\n", 5), EINA_FALSE);
        goto post_send;
     }

   net->refcount++;
   sprintf((char *)chunk_size, "%" PRIx64 "\r\n", data->size);
   chunk_data = eina_binbuf_new();
   eina_binbuf_append_length(chunk_data, (unsigned char *)chunk_size, strlen(chunk_size));
   eina_binbuf_append_length(chunk_data, data->data, data->size);
   eina_binbuf_append_length(chunk_data, (unsigned char *)"\r\n", 2);
   EINA_SAFETY_ON_NULL_RETURN_VAL(module->client->current->conn, EINA_FALSE);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(!ecore_con_client_send(module->client->current->conn,
                                  eina_binbuf_string_get(chunk_data), eina_binbuf_length_get(chunk_data)), EINA_FALSE);
   eina_binbuf_free(chunk_data);


post_send:
   if (nullify) module->client->current = NULL;
   return EINA_TRUE;
}