How rational-kunal/p2p-rock-paper-scissor works
Main Components
A. Client Layer (iOS Devices)
• Host Device
• Peer Device(s)
B. Application Layer
• View Layer
• Game Logic Layer
• Network Layer
Detailed Component Breakdown
A. View Layer (UI Components):
• StartMenuView
• GameView
• Main.storyboard
• LaunchScreen.storyboard
B. Model Layer:
• GameState
• Hand
• SessionState
C. Service Layer:
• GameSessionService (Core networking component)
D. Controller Layer:
• ViewController
• SceneDelegate
• AppDelegate
• [Device 1] <-----> [Multipeer Connectivity] <-----> [Device 2]
For each device, create a layered architecture
• UI Layer
• ↕
• Controller Layer
• ↕
• Service Layer
• ↕
• Model Layer
Component Relationships
• Views → ViewController (user actions)
• ViewController → GameSessionService (game logic)
• GameSessionService → Models (state updates)
• GameSessionService ←→ Multipeer Connectivity (P2P communication)
Specific flows
a. Game Session Establishment:
• StartMenuView → ViewController → GameSessionService → Multipeer Connectivity
b. Game State Updates:
• GameView → ViewController → GameSessionService → Models
c. P2P Communication:
• Device 1 GameSessionService ←→ Multipeer Connectivity ←→ Device 2 GameSessionService
Important Details to Highlight
• Multipeer Connectivity framework integration
• Real-time game state synchronization
• Session management flow
• Player move handling
• Result calculation and distribution