64 lines
2.0 KiB
Markdown
64 lines
2.0 KiB
Markdown
# 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
|
|
|
|
1. Install Node.js and NPM if you haven't already:
|
|
- Download from [nodejs.org](https://nodejs.org/)
|
|
|
|
2. Clone or download this repository to your computer
|
|
|
|
3. Install dependencies:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
## Running the server
|
|
|
|
1. Start the server:
|
|
```bash
|
|
npm start
|
|
```
|
|
or
|
|
```bash
|
|
node server.js
|
|
```
|
|
|
|
2. 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
|
|
|
|
1. Make sure all devices (server and app clients) are on the same network
|
|
|
|
2. Open the ClassMG project in DevEco Studio
|
|
|
|
3. Update the `CHANNEL_API_CONFIG.baseUrl` in `entry/src/main/ets/common/ClassRoomService.ets` to:
|
|
```
|
|
http://<Your computer's IP address>:5243
|
|
```
|
|
|
|
4. Compile and run the ClassMG app on your devices
|
|
|
|
## Testing
|
|
|
|
1. Run the server on one computer
|
|
2. Run the ClassMG app on two different devices (or emulators)
|
|
3. Log in as a teacher on one device and create a class
|
|
4. Log in as a student on the other device and join the class using the class code
|
|
5. 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. |