Skip to content

๐Ÿš€ input ํƒœ๊ทธ์— ํ•œ๊ธ€ ์ž…๋ ฅ ํ›„, Enter๋ฅผ ๋ˆ„๋ฅด๋ฉด ํ•จ์ˆ˜๊ฐ€ ๋‘๋ฒˆ ํ˜ธ์ถœ๋˜๋Š” ์˜ค๋ฅ˜

Kang Chaeryeon edited this page Dec 1, 2024 · 1 revision

๋ฌธ์ œ ์ƒํ™ฉ

image

  • ์ž…๋ ฅ์ฐฝ์— ๊ฐ’์„ ์ž…๋ ฅํ•˜๊ณ , ์˜†์˜ send ์•„์ด์ฝ˜์„ ๋ˆ„๋ฅด๋ฉด ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ, ์†Œ์ผ“์„ ํ†ตํ•ด ๋ฉ”์„ธ์ง€๋ฅผ ์ „์†กํ•˜๋„๋ก ๊ตฌํ˜„๋œ ์ƒํƒœ
  • ์ž…๋ ฅ์ฐฝ์— ๊ฐ’์„ ์ž…๋ ฅ ํ•˜๊ณ , Enter๋ฅผ ๋ˆŒ๋ ค๋„ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ณ ์ž, ๋‹ค์Œ๊ณผ ๊ฐ™์ด onKeyDown ์ด๋ฒคํŠธ๋ฅผ ์ถ”๊ฐ€
export default function ChatInput() {
  const [message, setMessage] = useState('');
  const { roomId } = useParams();

	// ์†Œ์ผ“์„ ํ†ตํ•ด ๋ฉ”์„ธ์ง€๋ฅผ ์ „์†ก
  const sendMessage = () => {
    socket.emit(
      'message',
      { message: message, roomId: roomId },
      (response: any) => {
        console.log(response);
      },
    );;
    setMessage('');
  };

  const handleOnKeyDown = (
    e: React.KeyboardEvent<HTMLInputElement>,
  ) => {
    if (e.key === 'Enter') {
      console.log('Enter');
      sendMessage();
    }
  };
  return (
    <div>
      <div className="flex flex-row">
        <input
          type="text"
          placeholder="์ฑ„ํŒ…์„ ์ž…๋ ฅํ•˜์„ธ์š”"
          className="bg-grayscale-700 rounded-lg w-full p-3 mr-2 focus:outline-none"
          onChange={(e) => setMessage(e.target.value)}
          value={message}
          onKeyDown={handleOnKeyDown}
        />
        <button onClick={sendMessage}>
          <SendIcon />
        </button>
      </div>
    </div>
  );
}
  • input ํƒœ๊ทธ์— onKeyDown ์ด๋ฒคํŠธ๋ฅผ ๋‹ฌ๊ณ , key๊ฐ€ Enter๋ผ๋ฉด ์†Œ์ผ“ ๋ฉ”์„ธ์ง€๋ฅผ ์ „์†กํ•˜๋„๋ก ๊ตฌํ˜„

image

โ›”๏ธ ์ด๋ฒคํŠธ๊ฐ€ 2๋ฒˆ์”ฉ ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜ ๋ฐœ์ƒ!!

์ด์ƒํ•œ ์ ์€ ์˜์–ด๋‚˜ ํŠน์ˆ˜๋ฌธ์ž๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ์—†์ง€๋งŒ, ํ•œ๊ธ€์„ ์ž…๋ ฅํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค

๋ฌธ์ œ ์›์ธ

IME(Input Method Editor) ๋•Œ๋ฌธ์ด์˜€๋‹ค

IME๋Š” ํ•œ๊ธ€๊ณผ ๊ฐ™์ด ์ž์Œ๊ณผ ๋ชจ์Œ์ด ๋ถ„๋ฆฌ๋˜์ง€ ์•Š๊ณ  ํ•œ ๊ธ€์ž๋กœ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์‹œ์Šคํ…œ ์†Œํ”„ํŠธ์›จ์–ด์ด๋‹ค

๋งˆ์ง€๋ง‰์œผ๋กœ ์ž…๋ ฅ๋œ ๊ธ€์ž๊ฐ€ ์™„์„ฑ๋œ ๊ธ€์ž์ธ์ง€,์™„๋ฃŒ๋˜์ง€ ์•Š์€ ๊ธ€์ž์ธ์ง€ ์•Œ ์ˆ˜ ์—†๊ธฐ๋•Œ๋ฌธ์—, ๊ฐ ์ƒํƒœ์— ๋Œ€ํ•ด 2๋ฒˆ ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ์ด๋‹ค

๋ฌธ์ œ ํ•ด๊ฒฐ

ํ•œ๊ธ€์ด ์™„์„ฑ๋œ ์ƒํƒœ๋ฅผ ์•Œ์•„์•ผํ•˜๋Š”๋ฐ, event ๊ฐ์ฒด์˜ isComposing์„ ํ†ตํ•ด ์•Œ ์ˆ˜ ์žˆ๋‹ค

image

๋ฆฌ์•กํŠธ๋Š” ํ•ฉ์„ฑ ์ด๋ฒคํŠธ(SyntheticBaseEvent) ์ด๋ฏ€๋กœ naviteEvent ์— ๋จผ์ € ์ ‘๊ทผํ•ด์„œ isComposing์„ ๊ฐ€์ ธ์™€์•ผ ํ•œ๋‹ค

  const handleOnKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
    if (e.nativeEvent.isComposing) {
      return;
    }
    if (e.key === 'Enter') {
      sendMessage();
    }
  };
  • ์™„์„ฑ๋˜์ง€ ์•Š์€ ์ƒํƒœ(isComposing === true) ์ธ ๊ฒฝ์šฐ, ๋ฐ”๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค

image

inear

๊ธฐ์ˆ  ๊ณต์œ 

๐Ÿš€ ffmpeg๋Š” stderr๋กœ ๋””๋ฒ„๊น…์„ ํ•˜๋Š” ์ด์œ 
๐Ÿš€ HLS ํ”„๋กœํ† ์ฝœ์— ๊ด€ํ•œ ์ •๋ฆฌ ๋ฐ FFmpeg ์‚ฌ์šฉ๊ธฐ
๐Ÿš€ ๋น„ํŠธ๋Š” tsconfig.json์ด ์„ธ ๊ฐœ?
๐Ÿš€ NestJS ๊ธฐ๋ณธ ๊ฐœ๋… - Modules
๐Ÿš€ Socket.io ์ตœ(๊ฐ•)์ ํ™”
๐Ÿš€ ๋„์ปค์™€ nginx์˜ ์‚ฌ์šฉ๊ธฐ
๐Ÿš€ ๋ถ€ํ•˜ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด์ž

๊ฐœ๋ฐœ ์ผ์ง€

๐Ÿš€ FSD ์‚ฌ์šฉ๊ธฐ, ๊ทผ๋ฐ ์ด์ œ ๋‚˜๋งŒ์˜ ๊ทœ์น™์„ ๊ณ๋“ค์ธ
๐Ÿš€ CICD ๊ตฌ์กฐ ์ˆ˜์ •
๐Ÿš€ ์•จ๋ฒ” ๋‹จ์œ„๋กœ ์ŠคํŠธ๋ฆฌ๋ฐ ํ•˜๊ธฐ (with HLS)
๐Ÿš€ HLS๋กœ ์Œ์•… ์ฃผ๊ณ ๋ฐ›๊ธฐ
๐Ÿš€ vite + react + typescript ํ™˜๊ฒฝ์—์„œ path alias ์„ค์ •
๐Ÿš€ React Scan์ด ๋ญ์ฃ ?
๐Ÿš€ ๋กœ์ปฌ ํ™˜๊ฒฝ ๊ฐœ๋ฐœ ๋ชจ๋“œ ๋ฐฐํฌ
๐Ÿš€ ์•จ๋ฒ” ์ „์ฒด๋ฅผ ์ŠคํŠธ๋ฆฌ๋ฐํ•œ๋‹ค๊ณ ? (with HLS)
๐Ÿš€ ์ฝ”๋“œ์˜ ์•ˆ์ •์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•ด ํ…Œ์ŠคํŠธ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด๋ณด์ž

ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…

๐Ÿš€ ์ƒˆ๋กœ๊ณ ์นจ ์‹œ HLS ERROR
๐Ÿš€ input ํƒœ๊ทธ์— ํ•œ๊ธ€ ์ž…๋ ฅ ํ›„, Enter๋ฅผ ๋ˆ„๋ฅด๋ฉด ํ•จ์ˆ˜๊ฐ€ ๋‘๋ฒˆ ํ˜ธ์ถœ๋˜๋Š” ์˜ค๋ฅ˜
๐Ÿš€ nginx proxy pass๋ฅผ ๋ฐ”๊ฟจ๋”๋‹ˆ ์ƒ๊ธด ์—๋Ÿฌ - ์Šค์›จ๊ฑฐ ์ธ์‹ ๋ฌธ์ œ
๐Ÿš€ ๋ฐฐํฌ ํ™˜๊ฒฝ์—์„œ ํด๋ผ์ด์–ธํŠธ-์„œ๋ฒ„ WS handshake
๐Ÿš€ ๋ Œ๋”๋ง ๋ฒ”์ธ์€ ํ•˜๋‚˜!

ํ˜‘์—… ๊ทœ์น™

๐ŸŒˆ ๊ทธ๋ผ์šด๋“œ ๋ฃฐ
๐Ÿฅ” ํŒ€์› ์†Œ๊ฐœ
๐Ÿ”Ž ์ฝ”๋“œ & ๊นƒ ์ปจ๋ฒค์…˜
๐ŸŒณ ๊นƒ branch ์ „๋žต
๐Ÿ“Œ ๋…ธ์…˜ ๋ฌธ์„œ ์ €์žฅ์†Œ

ํ”„๋กœ์ ํŠธ ๊ธฐํš

๐ŸŽจ ํ”ผ๊ทธ๋งˆ
๐Ÿง‘โ€๐Ÿ’ป ๊ธฐํš ๊ณต์œ  ๋ฐœํ‘œ ์ž๋ฃŒ
๐ŸŽค 2์ฃผ์ฐจ ๋ฐœํ‘œ ์ž๋ฃŒ
๐Ÿ˜Ž ๋ฐฑ๋กœ๊ทธ

๋ฐ์ผ๋ฆฌ ์Šคํฌ๋Ÿผ

๐Ÿ“ 1์ฃผ์ฐจ
๐Ÿ“ 2์ฃผ์ฐจ
๐Ÿ“ 3์ฃผ์ฐจ
๐Ÿ“ 4์ฃผ์ฐจ
๐Ÿ“ 5์ฃผ์ฐจ

์ฃผ๊ฐ„ ๊ณ„ํš์„œ

๐Ÿ—“๏ธ 1์ฃผ์ฐจ
๐Ÿ—“๏ธ 2์ฃผ์ฐจ
๐Ÿ—“๏ธ 3์ฃผ์ฐจ
๐Ÿ—“๏ธ 4์ฃผ์ฐจ
๐Ÿ—“๏ธ 5์ฃผ์ฐจ

๊ทธ๋ฃน ํšŒ๊ณ 

โœจ 1์ฃผ์ฐจ
โœจ 2์ฃผ์ฐจ
โœจ 3์ฃผ์ฐจ
โœจ 4์ฃผ์ฐจ


view

Clone this wiki locally