+void friend_timeout(struct friend *friend)
+{
+ if (friend->state == STATE_PINGED) {
+ friend->state = STATE_OFFLINE;
+ }
+}
+
+void friend_got_message(struct friend *friend, char *buffer, size_t len)
+{
+ if (len >= 4 && !strncmp(buffer, "PING", 4)) {
+ pong(friend);
+ } else if (len >= 4 && !strncmp(buffer, "PONG", 4)) {
+ friend->state = STATE_ONLINE;
+ }
+}
+