ClassMG Communication Server
This server enables real-time communication between multiple instances of the ClassMG application running on different devices. It provides a simple HTTP API for message passing, classroom management, and question handling.
Prerequisites
- Node.js (v12 or higher)
- NPM (Node Package Manager)
Installation
-
Install Node.js and NPM if you haven't already:
- Download from nodejs.org
-
Clone or download this repository to your computer
-
Install dependencies:
npm install
Running the server
-
Start the server:
npm start
or
node server.js
-
The server will start on port 5243. Make note of your computer's IP address, which will be displayed in the console output.
Connecting ClassMG app to the server
-
Make sure all devices (server and app clients) are on the same network
-
Open the ClassMG project in DevEco Studio
-
Update the
CHANNEL_API_CONFIG.baseUrl
inentry/src/main/ets/common/ClassRoomService.ets
to:http://<Your computer's IP address>:5243
-
Compile and run the ClassMG app on your devices
Testing
- Run the server on one computer
- Run the ClassMG app on two different devices (or emulators)
- Log in as a teacher on one device and create a class
- Log in as a student on the other device and join the class using the class code
- Test messaging, question publishing, and answering functionality
Troubleshooting
- Connection Issues: Make sure all devices are on the same network and can reach the server's IP address
- Port Conflicts: If port 5243 is already in use, change the PORT variable in server.js and update the app accordingly
- CORS Issues: If experiencing cross-origin problems, verify the CORS middleware is correctly configured in server.js
Note
This is a development server intended for local testing only. For production use, additional security measures would be required.