1. Namespace 연결

    const opt = {
      auth: {
        token: `Bearer ${accessToken}`,
      },
    };
    const helloSocket = io(`${url}:${port}/socket/commu-${communiyId}`, opt);
    
  2. 커뮤니티 별 채널 정보 전달

    helloSocket.emit('join', { channels: ['a', 'b', 'c'] });
    
  3. 새로운 메세지 전달

    저장
    POST http://{{ip}}:{{api_port}}/api/channels/:channel_id/chat
    수정
    PATCH http://{{ip}}:{{api_port}}/api/channels/:channel_id/chats/:chat_id
    삭제
    DELETE http://{{ip}}:{{api_port}}/api/channels/:channel_id/chats/:chat_id
    
    
    // sender 
    helloSocket.emit(
        'chat',
        {
          chatType: 'new'
          channelId: string,
          content: string,
        } as data,
        callback,
      );
    
    api body = {
          type: 'TEXT',
          content: data.message,
    }
    
    const apiResult = {
        "id": 51,
    		"type": "TEXT",
        "content": "hi",
        "senderId": "6394cc8fd1a615bf564d7e75",
    		"createdAt": "2022-12-11T16:13:24.957Z",
    		"updatedAt": "2022-12-11T16:13:24.957Z",
    
        "channelId": "6394cd01d1a615bf564d9e4c",
    		"communityId" : "",
    }
     
    
    reponse: { written: true; chatInfo : apiResult } | { written: false }
    
    helloSocket.on('new-chat', apiResult );
    
  4. 수정된 메세지 전달

  5. 삭제할 메세지 전달

    // sender  (커뮤니티 매니저, 채널 매니저, 작성자만 지우기 가능)
    helloSocket.emit(
        'chat',
        {
          chatType: 'delete',
          channelId: string,
    			chatId: number, // number아닌가?
        } as data,
        callback,
      );
    
    const apiResult = {
        "id": 51,
    		"type": "TEXT",
        "content": "hi",
    		"createdAt": Date(),
    		"updatedAt": Date(),
        "senderId": "6394cc8fd1a615bf564d7e75",
    
    		"communityId" : "",
        "channelId": "6394cd01d1a615bf564d9e4c",
    }
     
    
    reponse: { written: true; chatInfo : apiResult } | { written: false }
    helloSocket.on('delete-chat', apiResult );
    
  6. 채널 초대

    // 초대 sender
    helloSocket.emit(
        'invite-users-to-channel',
    			{
    				community_id: string; // 이거 카멜케이스?
    			  channel_id: string; // 이거 카멜케이스?
    			  users: string[];
    			}
        callback,
      );
    // 초대 receiver
    helloSocket.on(
        'invited-to-channel',
        {
    			 _id: '63946d71d0e70368d5be77fa',
    			managerId: '63908bdc2258e789af7d73ba',
    			name: 'dfa',
    			isPrivate: true,
    			description: '',
    			type: 'Channel',
    //		users: [ '63908bdc2258e789af7d73ba', '63908bcc2258e789af7d73ad' ],
    			createdAt: '2022-12-10T11:28:49.904Z',
    			updatedAt: '2022-12-10T11:28:59.207Z',
    			existUnreadChat: false,
    //
    			communityId : '', // 이거 카멜케이스?
    		}
      );