Features
chat
friends
unread

Direct Messaging

One-to-one chat with polling delivery, unread counts, and read receipts.

Overview

Tunnely's direct messaging system lets you chat with friends outside of game sessions. Messages are end-to-end encrypted, with real-time delivery status and unread tracking built in.

Quick Summary

  • 3s polling; loads last 50 messages per conversation
  • RLS ensures only friends can message
  • Unread badges, timestamps, read receipts (✓/✓✓)
  • Future: search, typing indicators, groups

How It Works

1

Messages poll every 3 seconds for new content, providing near-instant delivery without overwhelming the server.

2

Each conversation loads the most recent 50 messages, with older history accessible through pagination.

3

All messages are encrypted using RSA public-key cryptography - only you and your friend can read them.

4

Read receipts show delivery status: single checkmark for sent, double checkmark for read by recipient.

5

Unread counts appear as badges on the messages icon and update in real-time as you receive new messages.

Use Cases

Technical Details

  • Row-Level Security (RLS) enforces that only mutual friends can send messages to each other.
  • Messages use RSA-2048 encryption with keys generated and stored securely per user.
  • The polling mechanism includes exponential backoff on errors to preserve server resources.
  • Timestamps are stored in UTC and converted to local time for display.

Best Practices

  • Accept friend requests before attempting to message - RLS will block messages between non-friends.
  • If messages fail to decrypt, both users should re-login to refresh encryption keys.
  • Unread counts persist across sessions until you open and view the conversation.

Common Issues & Solutions

  • Encryption errors usually indicate key sync issues - have both users logout and login again.
  • If messages aren't appearing, check your network connection and verify the friend relationship is active.
  • Old conversations may take a moment to load if you have extensive message history.

TAGS

chat
friends
unread
read receipts