Skip to content

Commit

Permalink
chore: adding js-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
libterty committed Mar 16, 2021
1 parent 710e0ad commit c2da695
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/consumers/chat.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class ChatConsumerService {
this.init();
}

/**
* @description Init func
*/
init() {
this.consumer
.on('ready', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/sockets/chat.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class ChatSocketGateway {
this.init();
}

/**
* @description Init func
*/
public init() {
this.wss = new WebSocket.Server({ port: config.WSPORT, path: '/chats' });
this.wss.on('connection', (ws: WebSocket, req: Express.Request) => {
Expand Down
16 changes: 15 additions & 1 deletion src/sockets/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export class ChatSocketService {

constructor(private readonly chatSocketGateway: ChatSocketGateway) {}

/**
* @description Verify Identity
* @public
* @param {IChatRoom.ISocketWithIdentity} client
* @param {IChatRoom.IChatRoomEntity} chatRoom
* @returns {boolean}
*/
protected isRightClient(
client: IChatRoom.ISocketWithIdentity,
chatRoom: IChatRoom.IChatRoomEntity,
Expand All @@ -22,10 +29,17 @@ export class ChatSocketService {
return isClient;
}

/**
* @description send new chat room
* @public
* @param {EChatRoom.EChatRoomSocketEvent} type
* @param {IChatRoom.IChatRoomEntity} chatRoomEvent
* @returns {void}
*/
public sendNewChatRoom(
type: EChatRoom.EChatRoomSocketEvent,
chatRoomEvent: IChatRoom.IChatRoomEntity,
) {
): void {
this.chatSocketGateway.wss.clients.forEach(
(client: IChatRoom.ISocketWithIdentity) => {
const isClient = this.isRightClient(client, chatRoomEvent);
Expand Down

0 comments on commit c2da695

Please sign in to comment.