mirror of https://github.com/msantos/xmppipe
Generate a unique ID per message
Add a ID per message. Seems to fix the duplicate messages seen with MUCs on the Conversations android client whenever the network is switched (e.g., from wifi to cell). Introduce a dependency on Linux's libuuid which introduces portability issues. However, it should be simple to add support for the BSD UUID interface. libuuid was used because it is a fast and simple way of generating a unique id. Realistically, the ID only needs to be unique within the MUC and so could probably be replaced with an sprintf() combining time of day, PID and a random number.pull/1/head
parent
4325445536
commit
353951298e
@ -1,7 +1,7 @@
|
||||
RM=rm
|
||||
|
||||
all:
|
||||
$(CC) -g -Wall $(CFLAGS) -o xmppipe src/*.c $(LDFLAGS) -lstrophe
|
||||
$(CC) -g -Wall $(CFLAGS) -o xmppipe src/*.c $(LDFLAGS) -lstrophe -luuid
|
||||
|
||||
clean:
|
||||
-@$(RM) xmppipe
|
||||
|
@ -0,0 +1,30 @@
|
||||
/* Copyright (c) 2015, Michael Santos <michael.santos@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "xmppipe.h"
|
||||
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
char *
|
||||
xmppipe_id_alloc()
|
||||
{
|
||||
uuid_t uu = {0};
|
||||
char *out = NULL;
|
||||
|
||||
out = xmppipe_calloc(1,37);
|
||||
uuid_generate(uu);
|
||||
uuid_unparse(uu, out);
|
||||
|
||||
return out;
|
||||
}
|
Loading…
Reference in New Issue