|
8 | 8 |
|
9 | 9 | - `REDIS_URI`
|
10 | 10 |
|
11 |
| -## Running Collab Service Individually |
| 11 | +## Running Collab Service Locally |
12 | 12 |
|
13 |
| -1. Set up and run Redis using `docker compose run --rm --name redis -p 6379:6379 redis`. |
| 13 | +1. Set up and run Redis using `docker compose run --rm --name collab-service-redis -p 6380:6379 collab-service-redis`. |
14 | 14 |
|
15 |
| -2. Open Command Line/Terminal and navigate into the `collab-service` directory. |
| 15 | +2. Comment out `REDIS_URI` in the `.env` file. |
16 | 16 |
|
17 |
| -3. Run the command: `npm install`. This will install all the necessary dependencies. |
| 17 | +3. Open Command Line/Terminal and navigate into the `collab-service` directory. |
18 | 18 |
|
19 |
| -4. Run the command `npm start` to start the Collab Service in production mode, or use `npm run dev` for development mode, which includes features like automatic server restart when you make code changes. |
| 19 | +4. Run the command `npm install`. This will install all the necessary dependencies. |
20 | 20 |
|
21 |
| -## Running Collab Service Individually with Docker |
| 21 | +5. Run the command `npm start` to start the Collab Service in production mode, or use `npm run dev` for development mode, which includes features like automatic server restart when you make code changes. |
22 | 22 |
|
23 |
| -1. Open the command line/terminal. |
| 23 | +## Running Collab Service with Docker |
24 | 24 |
|
25 |
| -2. Run the command `docker compose run collab-service` to start up the collab service and its dependencies. |
| 25 | +1. Open the Command Line/Terminal. |
| 26 | + |
| 27 | +2. Run the command `docker compose run collab-service` to start up the Collab Service and its dependencies. |
26 | 28 |
|
27 | 29 | ## After running
|
28 | 30 |
|
29 | 31 | 1. Using applications like Postman, you can interact with the Collab Service on port 3003. If you wish to change this, please update the `.env` file.
|
30 | 32 |
|
31 | 33 | 2. Setting up Socket.IO connection on Postman:
|
| 34 | + |
32 | 35 | - You should open 2 tabs on Postman to simulate 2 users in the Collab Service.
|
33 | 36 |
|
34 | 37 | - Select the `Socket.IO` option and set URL to `http://localhost:3003`. Click `Connect`.
|
35 |
| -  |
36 |
| - |
| 38 | +  |
| 39 | + |
37 | 40 | - Add the following events in the `Events` tab and listen to them.
|
38 |
| -  |
39 |
| - |
| 41 | +  |
| 42 | + |
40 | 43 | - To send a message, go to the `Message` tab and ensure that your message is being parsed as `JSON`.
|
41 |
| -  |
42 |
| - |
| 44 | +  |
| 45 | + |
43 | 46 | - In the `Event name` input, input the correct event name. Click on `Send` to send a message.
|
44 |
| -  |
| 47 | +  |
| 48 | + |
| 49 | +## Events Available |
45 | 50 |
|
46 |
| -## Events Available |
47 | 51 | | Event Name | Description | Parameters | Response Event |
|
48 |
| -|----------------|-----------------------------------|-------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 52 | +| -------------- | --------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
49 | 53 | | **join** | Joins a collaboration room. | `roomId` (string): ID of the room. | **room_full:** Notify the user if the room is full (only 2 users allowed).<br/>**connected:** Notify the user if successfully connected.<br/>**new_user_connected:** Notify the other user if a new user joins the room. |
|
50 | 54 | | **change** | Sends updated code to other user. | `roomId` (string): ID of the room.<br/>`code` (string): Updated code content. | **code_change:** Notify the other user with the updated code content. |
|
51 | 55 | | **leave** | Leaves the collaboration room. | `roomId` (string): ID of the room. | **partner_left:** Notify the other user when one leaves the room. |
|
52 |
| -| **disconnect** | Disconnects from the server. | None | **partner_disconnected:** Notify the other user when one is disconnected. | |
| 56 | +| **disconnect** | Disconnects from the server. | None | **partner_disconnected:** Notify the other user when one is disconnected. | |
0 commit comments