basic server chat action find connected users
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
OnGatewayConnection,
|
||||
OnGatewayDisconnect,
|
||||
} from '@nestjs/websockets';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { PaginationQueryDto } from 'src/common/dto/pagination-query.dto';
|
||||
|
||||
@WebSocketGateway(5000, {
|
||||
path: '/chat',
|
||||
@@ -14,16 +16,24 @@ import {
|
||||
export class ChatGateway
|
||||
implements OnGatewayConnection, OnGatewayDisconnect
|
||||
{
|
||||
constructor
|
||||
(
|
||||
private usersService: UsersService,
|
||||
) {}
|
||||
|
||||
@WebSocketServer()
|
||||
server;
|
||||
|
||||
// how to guard the handleConnection ?
|
||||
// https://github.com/nestjs/nest/issues/882
|
||||
handleConnection(client) {
|
||||
console.log('---- Client connected :', client.id);
|
||||
async handleConnection(client) {
|
||||
const paginationQuery = new PaginationQueryDto();
|
||||
const users = await this.usersService.findAll(paginationQuery);
|
||||
console.log('---- Client connected :', client.id);
|
||||
console.log('users :', users);
|
||||
}
|
||||
handleDisconnect(client) {
|
||||
console.log('---- client disconnected:', client.id);
|
||||
console.log('---- client disconnected :', client.id);
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user