This is a standalone Socket.IO server for the MNS Phone application. It handles real-time communication for the game, including room management, gameplay events, and synchronization between players.
- Room creation and management
- Player connection handling
- Game state synchronization
- Drawing and sentence submission
- Presentation mode for game results
- Node.js (v16+)
- npm or yarn
- Clone the repository:
git clone https://github.com/YourUsername/mnsphone-server.git
cd mnsphone-server- Install dependencies:
npm install
# or
yarn install- Configure environment variables:
Copy the
.env.examplefile to.envand update the values as needed:
cp .env.example .envEdit the .env file to configure:
PORT: The port the server will run on (default: 3001)ALLOWED_ORIGINS: Comma-separated list of origins allowed to connect to the serverLOG_LEVEL: Level of logging (info, debug, error)
npm run dev
# or
yarn devBuild the server:
npm run build
# or
yarn buildStart the server:
npm start
# or
yarn start- Set up a VPS with Node.js installed (v16+)
- Clone the repository to your VPS
- Install dependencies
- Configure environment variables
- Build the server
- Set up a process manager like PM2:
npm install -g pm2
pm2 start dist/index.js --name mnsphone-server
pm2 save
pm2 startupUpdate your frontend to connect to this Socket.IO server by setting the appropriate connection URL in your Socket.IO client:
const socket = io('https://your-server-domain.com', {
transports: ['polling'],
withCredentials: true
});MIT