forked from quic-issues/427e7578-d7bf-49c8-aee9-2dd999e25316
fea88b277ccacdc3dc020014f2217e6523222176
- Add peer-to-peer polling with real-time synchronization via PeerJS - Implement vote changing, unvoting, and proper vote validation - Add modal interface for adding poll options - Fix vote inheritance issues for new users joining rooms - Create sidebar with available polls and connected peers - Add vote count synchronization across all connected peers - Implement proper vote state validation per user - Add localStorage persistence for polls and vote states - Create responsive design with modern UI components - Replace emojis with proper text-based icons - Add comprehensive error handling and user feedback - Support multiple polls with switching capabilities - Implement conflict resolution for concurrent voting
P2P Poll App
A peer-to-peer polling application where users can create polls, add options, and vote in real-time without a central server.
Features
- Real-time P2P voting using WebRTC via PeerJS
- Dynamic option management - add/remove options during polling
- Duplicate vote prevention - one vote per user
- Automatic data synchronization across all connected peers
- Local storage persistence for poll recovery
- Responsive design works on desktop and mobile
- No server required - uses PeerJS free signaling service
How to Use
- Open the app in your browser (open
index.html) - First user (Host): Leave the Peer ID field empty and click "Connect to Host"
- Copy your Peer ID using the "Copy Your Peer ID" button
- Share your Peer ID with other users (via chat, email, etc.)
- Other users: Paste the host's Peer ID and click "Connect to Host"
- Create a poll with question and options
- Vote by clicking on options (one vote per person)
- Watch results update in real-time across all devices
Technical Details
- P2P Library: PeerJS (WebRTC-based)
- Frontend: Vanilla JavaScript with modern CSS
- Data Sync: Custom conflict resolution for concurrent operations
- Storage: localStorage for basic persistence
- Network: Full mesh topology where each peer connects to all others
File Structure
├── index.html # Main application
├── css/
│ └── styles.css # Application styling
└── js/
├── app.js # Main application logic
├── peer-manager.js # P2P connection handling
├── poll-manager.js # Poll data and sync logic
└── ui-controller.js # UI interactions
Browser Support
Requires modern browsers with WebRTC support:
- Chrome 23+
- Firefox 22+
- Safari 11+
- Edge 79+
Development
Simply open index.html in a browser - no build process required. For testing with multiple peers, open the app in multiple browser tabs or windows.
Description