-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat <back> <chat, websockets>: storing websockets and userIds + receiver joins DM Room when creating DM room #58
Conversation
Every time a user connects, we store his socket ID and associate it to its userID. Every time a user disconnects, we delete the entry from the array.
Before, only the sender joined the room that was created, like a channel. But in a DM, both users have to join the channel. Now that we stock websockets, it is possible.
To make the receiver join the room only when he is connected
New feature in this PR (I decided to do it in this branch because it cannot work if this PR is not in main). |
If you want, when you have this kind of issue, create a branch, from the one you did a pr on, and so, you can start working on dependant feature like that :) Just don't do a pr for the child branch before the other one did pass ! :)
|
great tip, I'm having the same concern :)\ |
Sorry I have no idea how the codes work :), so I can not say it's good or not. Just one thing comes up to my mind. Should we propose some ways to test what you guys have done in a PR? (you can put it in the comments, a guide, or a test. Show us how to test the work, which results should we have, in console or whatever). Otherwise with people like me, I don't understand the code and I don't know which result it should give, I feel it's kind of wasting time to read blindly and don't get much knowledge. Maybe I don't understand the code, but at least I should be able to see the results. For example, from pure front-end, you guys can test it easily because it's visual. But with work in fusion, I created some tests for you either on the site, or in the console to prove that it works (with backend). It takes more time for me, but it helps people who does not work on it have some ideas on how it should work. |
test : offerings tests for #58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything wrong appart from my comment, but as thi said, didn't know how to test this one ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaah, I meant to approve, don't know what I did wrong sorry u_u'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve, but if you can make this little change.
backend/src/chat/chat.gateway.ts
Outdated
// @UseGuards(JwtWsGuard) | ||
// @SubscribeMessage(ROUTES_BASE.CHAT.BAN_USER_REQUEST) | ||
// async banUser( | ||
// @MessageBody() data: { message: string; channelId: number }, | ||
// @UserPayload() payload: any, | ||
// ) { | ||
// | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this is the next PR.
Next time try to separate them.
export class UsersWebsockets { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you didn't change the file's name.
Can you change it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, i forgot.
backend/src/chat/chat.gateway.ts
Outdated
@@ -49,7 +52,27 @@ export class ChatGateway { | |||
|
|||
@WebSocketServer() | |||
server: Server; | |||
async handleConnection(client: Socket) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add the decorator ?
async handleConnection(@ConnectedSocket() client: Socket) {
backend/src/chat/chat.gateway.ts
Outdated
} | ||
} | ||
|
||
handleDisconnect(client: Socket) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i ask for change of interface/charRoom.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the name of interfaces/ChatRoom.ts ?
Sorry for the multiple message. i am tired.
It is done, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer all stuff concern user in user/something.
But i need your code, so i approve it 😅
@@ -24,7 +24,7 @@ export class ChatService { | |||
private usersRepository: Repository<User>, | |||
private userService: UsersService, | |||
) {} | |||
private static chatRoomList: ChatRoom[] = []; | |||
public static userWebsockets: UsersWebsockets[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we said by oral, i prefer having a userGateway.
But i need your code, so a approve it 😅
test : offerings tests for #58
Feat <back> <chat, websockets>: storing websockets and userIds + receiver joins DM Room when creating DM room
Every time a user connects, we store his socket ID and associate it to its userID.
Every time a user disconnects, we delete the entry from the array.