|
28 | 28 |
|
29 | 29 | ## After running
|
30 | 30 |
|
31 |
| -1. To view Matching Service documentation, go to http://localhost:3002/docs. |
| 31 | +1. Using applications like Postman, you can interact with the Matching Service on port 3002. If you wish to change this, please update the `.env` file. |
32 | 32 |
|
33 |
| -2. Using applications like Postman, you can interact with the Matching Service on port 3002. If you wish to change this, please update the `.env` file. |
| 33 | +2. Setting up Socket.IO connection on Postman: |
| 34 | + |
| 35 | + - You should open 2 tabs on Postman to simulate 2 users in the Matching Service. |
| 36 | + |
| 37 | + - Select the `Socket.IO` option and set URL to `http://localhost:3002`. Click `Connect`. |
| 38 | + |
| 39 | +  |
| 40 | + |
| 41 | + - Add the following events in the `Events` tab and listen to them. |
| 42 | + |
| 43 | +  |
| 44 | + |
| 45 | + - In the `Headers` tab, add a valid JWT token in the `Authorization` header. |
| 46 | + |
| 47 | +  |
| 48 | + |
| 49 | + - In the `Message` tab, select `JSON` in the bottom left dropdown to ensure that your message is being parsed correctly. In the `Event name` input field, enter the name of the event you would like to send a message to. Click on `Send` to send a message. |
| 50 | + |
| 51 | +  |
| 52 | + |
| 53 | +## Events Available |
| 54 | + |
| 55 | +| Event Name | Description | Parameters | Response Event | |
| 56 | +| ------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 57 | +| **user_connected** | User joins the matching process | `uid` (string): ID of the user. | None | |
| 58 | +| **user_disconnected** | User leaves the matching process | `uid` (string): ID of the user. | **match_unsuccessful**: If the user left during the match offer phase, notify the partner user that the match was unsuccessful | |
| 59 | +| **match_request** | Sends a match request | `matchRequest` (`MatchRequest`): Match request details. <br><br> `callback` (`(requested: boolean) => void`): To check if the match request was successfully sent. | **match_request_exists**: Notify the user that only one match request can be processed at a time. <br><br> **match_request_error**: Notify the user that the match request failed to send. | |
| 60 | +| **match_cancel_request** | Cancels the match request | `uid` (string): ID of the user. | None | |
| 61 | +| **match_accept_request** | Accepts the match request | `uid` (string): ID of the user. | **match_successful**: If both users have accepted the match offer, notify them that the match is successful. | |
| 62 | +| **match_decline_request** | Declines the match request | `uid` (string): ID of the user. <br><br> `matchId` (string): ID of the user. <br><br> `isTimeout` (boolean): Whether the match was declined due to match offer timeout. | **match_unsuccessful**: If the match was not declined due to match offer timeout (was explicitly rejected by the user), notify the partner user that the match is unsuccessful. | |
| 63 | +| **rematch_request** | Sends a rematch request | `matchId` (string): ID of the match. <br><br> `partnerId` (string): ID of the partner user. <br><br> `rematchRequest` (`MatchRequest`): Rematch request details. <br><br> `callback` (`(requested: boolean) => void`): To check if the rematch request was successfully sent. | **match_request_error**: Notify the user that the rematch request failed to send. | |
| 64 | +| **match_end_request** | User leaves the matching process upon leaving the collaboration session | `uid` (string): ID of the user. <br><br> `matchId` (string): ID of the match. | None | |
| 65 | + |
| 66 | +### Event Parameter Types |
| 67 | + |
| 68 | +```typescript |
| 69 | +interface MatchUser { |
| 70 | + id: string; |
| 71 | + username: string; |
| 72 | + profile?: string; |
| 73 | +} |
| 74 | + |
| 75 | +interface MatchRequest { |
| 76 | + user: MatchUser; |
| 77 | + complexity: string; |
| 78 | + category: string; |
| 79 | + language: string; |
| 80 | + timeout: number; |
| 81 | +} |
| 82 | +``` |
0 commit comments