Ping a friend when we get it from the cache
[cascardo/f2fchat.git] / message.c
index 1a66892..8e3202d 100644 (file)
--- a/message.c
+++ b/message.c
@@ -52,6 +52,15 @@ gboolean message_incoming(GIOChannel *channel, GIOCondition cond, gpointer data)
        iaddress = g_inet_socket_address_get_address(G_INET_SOCKET_ADDRESS(address));
        if (g_inet_address_get_is_loopback(iaddress)) {
                command(buffer, len);
+       } else {
+               struct friend *friend;
+               friend = friend_get_by_address(iaddress);
+               if (friend) {
+                       printf("got message from %s\n", friend_get_name(friend));
+                       g_source_remove_by_user_data(friend);
+               } else {
+                       printf("could not find friend from address %s\n", g_inet_address_to_string(iaddress));
+               }
        }
        g_object_unref(address);
        g_free(buffer);