Skip to content

puppleberry/OSSW_team

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

62 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OSSW_TeamProject


1. ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ

1.1. ๋ฌด์Šจ ํ”„๋กœ์ ํŠธ์ธ๊ฐ€?

์›น์„ ํ†ตํ•ด์„œ ์„œ๋ฒ„์— ์ ‘์†ํ•˜์—ฌ ํ•ด๋‹น ์›น์— ์ ‘์†ํ•œ ์‚ฌ๋žŒ๋ผ๋ฆฌ ์ต๋ช…์œผ๋กœ ๋Œ€ํ™”๋ฅผ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ๋Š” ์‹œ์Šคํ…œ.

1.2. ํ”„๋กœ์ ํŠธ ์‚ฌ์šฉ ์˜ˆ์‹œ

USERS

  • ์›น ์‚ฌ์ดํŠธ ์ ‘์†
  • ์‚ฌ์šฉ์ž๋ช… ์ž…๋ ฅ (์ž…๋ ฅํ•˜์ง€ ์•Š์„ ์‹œ ์ž„์˜์˜ ์ต๋ช… ๋‹‰๋„ค์ž„์œผ๋กœ ์„ค์ • ๋จ)
  • ์ฑ„ํŒ… ํ…์ŠคํŠธ ์นธ์— ํ…์ŠคํŠธ ์ž…๋ ฅ ํ›„, ์ „์†ก ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ํด๋ผ์ด์–ธํŠธ์˜ ๋ฉ”์„ธ์ง€ ์ „์†ก

SERVER

  • ์ž„์˜์˜ ํด๋ผ์ด์–ธํŠธ A ์ ‘์†์‹œ A์—๊ฒŒ ์ด๋ฆ„์„ ๋ฐ›์•„์™€ ์›น์— ์ ‘์†ํ•œ ๋ชจ๋“  ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ž…์žฅ ๋ฉ”์„ธ์ง€ ํ‘œ์‹œ
  • ์ž„์˜์˜ ํด๋ผ์ด์–ธํŠธ A๊ฐ€ ๋ฉ”์„ธ์ง€ ์ „์†ก ์‹œ ๋ชจ๋“  ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ํ•ด๋‹น ๋ฉ”์„ธ์ง€์™€ ํ•ด๋‹น ํด๋ผ์ด์–ธํŠธ์˜ ์ด๋ฆ„ ํ‘œ์‹œ
  • ์ž„์˜์˜ ํด๋ผ์ด์–ธํŠธ A ํ‡ด์žฅ์‹œ ์›น์— ์ ‘์†ํ•œ ๋ชจ๋“  ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ํ‡ด์žฅ ๋ฉ”์„ธ์ง€ ํ‘œ์‹œ

1.3. ํ”„๋กœ์ ํŠธ ์—ญํ•  ๋ถ„๋ฐฐ

์†ก์ง„์šฐ

  • ๋ฐฑ์—”๋“œ ์„œ๋ฒ„ ๊ตฌ์ถ•
  • ํ”„๋ก ํŠธ์—”๋“œ ์ฝ”๋“œ ์ผ๋ถ€ ์ˆ˜์ •
  • ๋ณด๊ณ ์„œ, ํšŒ์˜๋ก

๊น€๋™์šฑ

  • ํ”„๋ก ํŠธ HTML ํ…œํ”Œ๋ฆฟ ๊ฒ€์ƒ‰ ํ›„ ์—…๋กœ๋“œ
  • HTML ํ…œํ”Œ๋ฆฟ์—์„œ ํ•„์š”์—†๋Š” ๋ถ€๋ถ„ ์ œ๊ฑฐ ๋ฐ ์•ฝ๊ฐ„์˜ ์ˆ˜์ •
  • ๋ฐœํ‘œ ์ž๋ฃŒ ํ”„๋ฆฌ์  ํ…Œ์ด์…˜ ์ œ์ž‘

์ •๋ฏผ์šฐ

  • HTML ํ…œํ”Œ๋ฆฟ์— ํ•„์š”ํ•œ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ ๋ฐ ์ˆ˜์ •
  • CSS ์ผ๋ถ€ ์ˆ˜์ •
  • ๋ฐœํ‘œ ์ž๋ฃŒ ํ”„๋ฆฌ์  ํ…Œ์ด์…˜ ์ œ์ž‘

1.4. ์‚ฌ์šฉํ•œ ๊ธฐ์ˆ  ์Šคํƒ

BACK

  • node.js - github (MIT Lincense)
  • socket.io - github (MIT License)
  • express.js - github (MIT License)

FRONT

  • HTML
  • CSS
  • javascript

1.5. ์ฐธ๊ณ  ์ž๋ฃŒ REF

Backend

Frontend

1.6. ๋ผ์ด์„ ์Šค

node.js ์™€ socket.io์˜ ๋ผ์ด์„ ์Šค์™€ ๋™์ผํ•œ MIT License ์ ์šฉ.
html/css ๋ถ€๋ถ„์ด K์‚ฌ์˜ SNS ์•ฑ์˜ ์ƒ‰๊ฐ๊ณผ ๋น„์Šทํ•˜์ง€๋งŒ '์ƒ‰๊ฐ'์— ๋Œ€ํ•œ ์ €์ž‘๊ถŒ์€ ๋”ฐ๋กœ ์กด์žฌํ•˜์ง€ ์•Š์Œ.

์ฐธ๊ณ ์ž๋ฃŒ: ์ƒ‰๊ฐ


2. ํ”„๋กœ์ ํŠธ ๊นƒํ—ˆ๋ธŒ ์‚ฌ์šฉ ์šฉ๋„

2.1. git add / commit / push

์ผ๋ฐ˜์ ์œผ๋กœ ์—…๋ฐ์ดํŠธ ํ•œ ์ฝ”๋“œ๋ฅผ ๊นƒํ—ˆ๋ธŒ ์›๊ฒฉ์ €์žฅ์†Œ์— ์—…๋กœ๋“œ ํ•˜๊ธฐ์œ„ํ•ด์„œ ํ•ด๋‹น ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—…๋กœ๋“œํ•จ.

2.2. fork, branch, PR, merge

ํ”„๋กœ์ ํŠธ์— ์ฐธ๊ฐ€ํ•˜๋Š” ์ธ์› ๋ชจ๋‘ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋ฅผ forkํ•ด์„œ ๋ณธ์ธ ์ €์žฅ์†Œ์— ๋‘” ํ›„, branch๋กœ ์ž์‹ ์˜ ๋ช‡๋ฒˆ์งธ ํŒจ์น˜์ธ์ง€ ๊ตฌ๋ถ„,
ํŒจ์น˜ ํ•œ ์ดํ›„์— PR์„ ๋ณด๋‚ด์„œ mergeํ•ด์ฃผ๋Š” ์‹์œผ๋กœ ํ˜‘์—…์„ ์ง„ํ–‰ํ•จ.

2.3. release

๊นƒํ—ˆ๋ธŒ์˜ ์žฅ์ ์ธ ๋ฒ„์ „ ๊ด€๋ฆฌ๋ฅผ ์‚ฌ์šฉ์ž๋“ค๋„ ๋Š๋‚„ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ธฐ ์œ„ํ•ด์„œ ํฐ ๊ธฐ๋Šฅ์ด ์—…๋ฐ์ดํŠธ ๋  ๋•Œ ๋งˆ๋‹ค ๋ฒ„์ „์„ ๊ตฌ๋ถ„ํ•˜์—ฌ release ์‹œํ‚ด
pre-release, lateset-release ์‚ฌ์šฉ์€ ์ฝ”๋“œ๊ฐ€ ๋‹จ์ˆœํ•˜์—ฌ ์‹ฌ๊ฐํ•œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•  ์ผ์ด ์—†๊ณ , ์‚ฌ์šฉํ•˜๋Š” ์œ ์ €๊ฐ€ ํ•œ์ •๋˜์–ด์žˆ์œผ๋‹ˆ,
stable version, latese version๊ฐ™์€๊ฒƒ์„ ๊ตฌ๋ถ„ํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ธฐ ๋•Œ๋ฌธ.

2.4. issue

์ฝ”๋“œ์˜ ๋ฌธ์ œ๋ฅผ ๋ฐœ๊ฒฌํ•˜๋Š”๋ฐ, ํŒ€ ํ”„๋กœ์ ํŠธ๋ฅผ ๊ฐ™์ด ํ•˜๋Š” ํŒ€์›๋“ค๋ผ๋ฆฌ์˜ ๋ฉ”์‹ ์ €๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ์ฐพ์•„๋‚ด๊ณ  ์ˆ˜์ •ํ•ด๋„ ์ข‹์•˜๊ฒ ์ง€๋งŒ,
๊นƒํ—ˆ๋ธŒ์˜ issue๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด,
ํ•ด๋‹น issue๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋Š” ์‚ฌ์‹ค, ์–ด๋–ป๊ฒŒ ํ˜น์€ ์–ธ์ œ ๊ณ ์ณ์กŒ๋‚˜ ํ•˜๋Š” ์‚ฌ์‹ค, ๊ทธ๋ฆฌ๊ณ  ์—ฌ๋Ÿฌ ๊ธฐ๋Šฅ์„ ์ฒจ๊ฐ€ํ•˜์—ฌ ํ•œ๋ˆˆ์— ๋ณผ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ 
์ด๋Ÿฐ ์ด์œ ๋“ค ๋•Œ๋ฌธ์— github์˜ issue ๊ธฐ๋Šฅ์„ ํŒ€ ํ”„๋กœ์ ํŠธ์— ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

3. CODE explain, CODE documentation

3.1 app.js

3.1.1 constant setting part

// getting express module
const express = require('express')

// getting socket.io module
const socket = require('socket.io')

// getting node.js standard module
const path = require('path')
const http = require('http')

const fs = require('fs')
const app = express() // construct express object
const server = http.createServer(app) // construct http server
const io = socket(server) // binding the server

์จ์•ผ ํ•  ๋ชจ๋“ˆ์„ ๋ถˆ๋Ÿฌ์˜ค๊ณ , http ์„œ๋ฒ„๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์„œ๋ฒ„๋ฅผ ์†Œ์ผ“์— ๋ฐ”์ธ๋”ฉ ํ•˜๋Š” ๊ณผ์ •

3.1.2 event listen part

io.on('connection', function(socket) {

    socket.on('newUser', function(name){
        console.log(name + " connect");
        socket.name = name;
        io.emit('announce', name + " ๊ฐ€ ์ ‘์†ํ–ˆ์Šต๋‹ˆ๋‹ค.");
    });

    socket.on('chatting', function(data){
        console.log(data);
        const {name, msg} = data;
        socket.name = name;
        io.emit('chatting', data)
    });

    socket.on('disconnect', function(){
        console.log(socket.name + " disconnect");
        io.emit('announce', socket.name + " ๊ฐ€ ํ‡ด์žฅํ–ˆ์Šต๋‹ˆ๋‹ค.");
    })

});

์ด๋ฒคํŠธ๋ฅผ ์„ธ๊ฐ€์ง€๋กœ ๋‚˜๋ˆ„์–ด์„œ ๊ตฌ๋ถ„ํ•จ

  • 'newUser'
    • ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ ‘์†ํ•˜์˜€์„ ๋•Œ ์˜ค๋Š” ์ด๋ฒคํŠธ
  • 'chatting'
    • ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ฑ„ํŒ…ํ•  ๋•Œ ์˜ค๋Š” ์ด๋ฒคํŠธ
  • 'disconnect'
    • ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ ‘์†์„ ๋Š์—ˆ์„ ๋•Œ ์˜ค๋Š” ์ด๋ฒคํŠธ

3.2. index.js

3.2.1 constant setting

const socket = io();
const nickname = document.querySelector('#nickname');
const chatList = document.querySelector('.chatting-list');
const chatInput = document.querySelector('.chatting-input');
const sendButton = document.querySelector('.send-button');
const displayContainer = document.querySelector('.display-container');

html์˜ ์ฟผ๋ฆฌ๋ฅผ ๋‹ด์•„์„œ, ํ•ด๋‹น ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์ƒ์ˆ˜๋กœ ์„ ์–ธํ•ด์ฃผ๋Š” ๊ณผ์ •

3.2.2 event listening

socket.on('connect',function(){
    var name = prompt('ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค! ๋‹น์‹ ์„ ๋ญ๋ผ๊ณ  ์†Œ๊ฐœํ•˜๋‚˜์š”: ', '');
    if(!name){
      name = '์ต๋ช…์˜ ๋ˆ„๊ตฐ๊ฐ€'+ Math.floor(Math.random()*100);
    }
    nickname.defaultValue = name;
    socket.emit('newUser', name);
});

socket.on('chatting', function(data){
  const { name, msg } = data;
  const item = new Li(name, msg);
  item.makeLi();
  displayContainer.scrollTo(0, displayContainer.scrollHeight);
});

socket.on('announce', function(msg){
  const item = new announement(msg);
  item.makeAn();
  displayContainer.scrollTo(0, displayContainer.scrollHeight);
});
  • 'connect'
    • ๊ธฐ๋ณธ์œผ๋กœ ์„ค์ •๋˜์–ด์žˆ๋Š” ์ด๋ฒคํŠธ, ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ ‘์†ํ•˜๋ฉด ์ž๋™ ์‹คํ–‰ ๋จ, ์ด๋ฆ„์„ ์„ค์ •ํ•ด์ฃผ๊ณ  ๊ทธ ๋’ค์— ์„œ๋ฒ„๋กœ ๋„˜๊ฒจ์„œ newUser ์ด๋ฒคํŠธ ์‹คํ–‰์‹œํ‚ด.
  • 'chatting'
    • ์ฑ„ํŒ… ์ด๋ฒคํŠธ, HTML ์ฝ”๋“œ์˜ ์ฑ„ํŒ…๋ถ€๋ถ„ <li> ์ฟผ๋ฆฌ์— ์ผ๋ถ€ ์ฝ”๋“œ๋ฅผ ์‚ฝ์ž…ํ•˜์—ฌ์„œ(์ฑ„ํŒ…) ์ ์  ์ฑ„ํŒ…์„ ๋งŒ๋“ค์–ด ๋‚ด์ฃผ๋Š” ์ด๋ฒคํŠธ.
  • 'announce'
    • ๊ณต์ง€ ์ด๋ฒคํŠธ, HTML ์ฝ”๋“œ์˜ ์ฑ„ํŒ…๋ถ€๋ถ„ <li> ์ฟผ๋ฆฌ์— ์ผ๋ถ€ ์ฝ”๋“œ๋ฅผ ์‚ฝ์ž…ํ•˜์—ฌ์„œ(๊ณต์ง€) ๊ณต์ง€๋ฅผ ๋งŒ๋“ค์–ด ๋‚ด๋Š” ์ด๋ฒคํŠธ.

3.2.3 sending

chatInput.addEventListener('keypress', function(e){
  if (e.keyCode === 13) {
    send();
  }
});

function send() {
  const param = {
    name: nickname.value,
    msg: chatInput.value,
  };
  socket.emit('chatting', param);
}

sendButton.addEventListener('click', send);

์‹คํ–‰๋  ๋•Œ ์„œ๋ฒ„๋กœ chatting ์ด๋ฒคํŠธ๋ฅผ ๋ณด๋‚ด๋Š” send ํ•จ์ˆ˜๋ฅผ ์ œ์ž‘ํ•˜์—ฌ sendButton์— ๋ˆŒ๋ ธ์„ ๋•Œ send ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰์‹œํ‚ค๋„๋ก ํ•˜๊ณ  keypress, 13๋ฒˆ, ์—”ํ„ฐ๋ฅผ ๋ˆŒ๋ €์„ ๋•Œ send ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰์‹œํ‚ค๋„๋ก ํ•จ.