[mw-devel] MW3 r1389 - trunk/src/server
arthur at sucs.org
arthur at sucs.org
Mon Sep 21 16:52:44 BST 2015
Author: arthur
Date: 2015-09-21 16:52:39 +0100 (Mon, 21 Sep 2015)
New Revision: 1389
Added:
trunk/src/server/replay.c
trunk/src/server/replay.h
Log:
forgot to commit these two
Added: trunk/src/server/replay.c
===================================================================
--- trunk/src/server/replay.c (rev 0)
+++ trunk/src/server/replay.c 2015-09-21 15:52:39 UTC (rev 1389)
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/epoll.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include <socket.h>
+#include <nonce.h>
+#include <util.h>
+#include <rooms.h>
+#include <talker_privs.h>
+#include <ipc.h>
+
+#include "replay.h"
+
+static uint64_t serial = 0;
+
+
+/* look at the history and set the serial number
+ * appropriately.
+ */
+void load_serial(void)
+{
+ serial = 1;
+}
+
+/* store the message for later replay */
+void store_message(ipc_message_t *msg)
+{
+}
+
+/* assign a unique serial number to each message
+ * thus giving a definitive replay ordering
+ * also attach timestamp for human friendliness
+ */
+void assign_serial( ipc_message_t *msg )
+{
+ if (serial == 0) load_serial();
+ msg->head.serial = serial++;
+ msg->head.when = time(NULL);
+
+ store_message(msg);
+}
Added: trunk/src/server/replay.h
===================================================================
--- trunk/src/server/replay.h (rev 0)
+++ trunk/src/server/replay.h 2015-09-21 15:52:39 UTC (rev 1389)
@@ -0,0 +1,3 @@
+/* replay.c */
+void load_serial(void);
+void assign_serial(ipc_message_t *msg);
More information about the mw-devel
mailing list