Skip to content

apptrackit/chat-android

Repository files navigation

Vortex - Android P2P Chat

A peer-to-peer chat application for Android that mirrors the iOS implementation exactly. Uses WebRTC for direct communication and WebSocket signaling server.

Features

  • Real-time P2P messaging using WebRTC data channels
  • Same signaling server and TURN/STUN configuration as iOS app
  • Automatic reconnection on connection loss
  • Room-based chat system
  • Cross-platform compatibility with iOS version

Installation

cd /home/botond/AndroidStudioProjects/Vortex
./gradlew installDebug

Usage

  1. Launch the app - it will automatically connect to the signaling server
  2. Wait for "Connected" status - the status should change from "Connecting" to "Connected"
  3. Enter a Room ID (or leave blank for "default") and tap "Join Room"
  4. Chat with other users - open the iOS app or another Android instance in the same room
  5. Send messages - the "Send" button becomes enabled when P2P connection is established

Architecture

Components

  • ChatManager.kt - WebRTC peer connection management, WebSocket signaling, message handling
  • MainActivity.kt - Simple UI with status, room controls, message list, and input
  • ConnectionStatusAndroid - Connection state enum (DISCONNECTED, CONNECTING, CONNECTED)
  • ChatMessage - Data class for individual messages with timestamp and sender info

Network Configuration

  • Signaling Server: wss://chat.ballabotond.com
  • STUN Servers: Google STUN servers for NAT traversal
  • TURN Servers:
    • Primary: chat.ballabotond.com:3478 (UDP/TCP/TLS)
    • Fallback: openrelay.metered.ca (UDP/TCP)

Connection Flow

  1. WebSocket connects to signaling server
  2. Server sends "connected" message with client ID
  3. User joins room via "join_room" message
  4. When second user joins, server sends "room_ready" with initiator flag
  5. Initiator creates offer and data channel
  6. WebRTC negotiation (offer/answer/ICE candidates) via signaling
  7. P2P data channel opens for direct messaging

Debugging

Enable verbose logging to see connection details:

adb logcat | grep ChatManager

Key log messages to watch for:

  • 🔧 Setting up WebRTC... - WebRTC initialization
  • WebSocket opened - waiting for server confirmation - WebSocket connection
  • Connected to signaling server with ID: <id> - Successful server connection
  • 🎯 Room is ready! Both users connected - Room pairing successful
  • 🟢 Data channel: Open! Ready to send messages - P2P connection established
  • 📥 Received P2P message: '<message>' - Message received

Testing

  1. Single device: Use both Android and iOS apps
  2. Multiple devices: Install on different devices, same room ID
  3. Network conditions: Test on different networks (WiFi, mobile data)
  4. Connection recovery: Kill and restart app to test reconnection

Dependencies

  • Stream WebRTC: io.getstream:stream-webrtc-android:1.0.7
  • OkHttp: com.squareup.okhttp3:okhttp:4.12.0
  • Gson: com.google.code.gson:gson:2.10.1
  • Kotlinx Coroutines: org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1

Compatibility

  • Android API Level: 26+ (Android 8.0)
  • Target SDK: 35
  • Architecture: ARM64, ARMv7, x86, x86_64
  • Cross-platform: Compatible with iOS version using same protocols

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages