KGC 2014: 클라이언트 개발자를 위한 컴퓨터 네트워크 기초 배현직Hyunjik Bae
클라이언트 개발자들은 직접 서버와 네트워크를 다루지는 않더라도 컴퓨터 네트워크의 특징에 대해서는 알고 있어야 한다. 본 강연은 클라이언트 개발자들이 반드시 알아야 하는 컴퓨터 네트워크 관련 용어와 특징을 소개한다. 아울러 스마트폰 무선 네트워크 관련해서 주안점도 다룬다.
KGC 2014: 클라이언트 개발자를 위한 컴퓨터 네트워크 기초 배현직Hyunjik Bae
클라이언트 개발자들은 직접 서버와 네트워크를 다루지는 않더라도 컴퓨터 네트워크의 특징에 대해서는 알고 있어야 한다. 본 강연은 클라이언트 개발자들이 반드시 알아야 하는 컴퓨터 네트워크 관련 용어와 특징을 소개한다. 아울러 스마트폰 무선 네트워크 관련해서 주안점도 다룬다.
2017년 3월 22일 re:View 1st Impact
"코드리뷰를 시작하려는 그대에게" 세션 발표 내용입니다
자세한 행사 내용은 아래 링크를 참고해주시기 바랍니다 ^^
https://reviewmeetup.wordpress.com/2017/03/11/review-1st-impact-20170322/
How to Become a Thought Leader in Your NicheLeslie Samuel
Are bloggers thought leaders? Here are some tips on how you can become one. Provide great value, put awesome content out there on a regular basis, and help others.
2017년 3월 22일 re:View 1st Impact
"코드리뷰를 시작하려는 그대에게" 세션 발표 내용입니다
자세한 행사 내용은 아래 링크를 참고해주시기 바랍니다 ^^
https://reviewmeetup.wordpress.com/2017/03/11/review-1st-impact-20170322/
How to Become a Thought Leader in Your NicheLeslie Samuel
Are bloggers thought leaders? Here are some tips on how you can become one. Provide great value, put awesome content out there on a regular basis, and help others.
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
Thinking about your sales team's goals for 2017? Drift's VP of Sales shares 3 things you can do to improve conversion rates and drive more revenue.
Read the full story on the Drift blog here: http://blog.drift.com/sales-team-tips
An immersive workshop at General Assembly, SF. I typically teach this workshop at General Assembly, San Francisco. To see a list of my upcoming classes, visit https://generalassemb.ly/instructors/seth-familian/4813
I also teach this workshop as a private lunch-and-learn or half-day immersive session for corporate clients. To learn more about pricing and availability, please contact me at http://familian1.com
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
We asked LinkedIn members worldwide about their levels of interest in the latest wave of technology: whether they’re using wearables, and whether they intend to buy self-driving cars and VR headsets as they become available. We asked them too about their attitudes to technology and to the growing role of Artificial Intelligence (AI) in the devices that they use. The answers were fascinating – and in many cases, surprising.
This SlideShare explores the full results of this study, including detailed market-by-market breakdowns of intention levels for each technology – and how attitudes change with age, location and seniority level. If you’re marketing a tech brand – or planning to use VR and wearables to reach a professional audience – then these are insights you won’t want to miss.
The technologies and people we are designing experiences for are constantly changing, in most cases they are changing at a rate that is difficult keep up with. When we think about how our teams are structured and the design processes we use in light of this challenge, a new design problem (or problem space) emerges, one that requires us to focus inward. How do we structure our teams and processes to be resilient? What would happen if we looked at our teams and design process as IA’s, Designers, Researchers? What strategies would we put in place to help them be successful? This talk will look at challenges we face leading, supporting, or simply being a part of design teams creating experiences for user groups with changing technological needs.
No borders innovation: how to build a remote working-based “liquid company”Emanuela Zaccone
Which are the advantages of working remotely? What does it mean for startups?
Let’s talk about case histories - from TOK.tv to Automattic -, methodologies and practices to turn a traditional working environment into a remote one by creating a “liquid company”.
TEDx Manchester: AI & The Future of WorkVolker Hirsch
TEDx Manchester talk on artificial intelligence (AI) and how the ascent of AI and robotics impacts our future work environments.
The video of the talk is now also available here: https://youtu.be/dRw4d2Si8LA
2. 개발 배경…
4학년 끝나갈 무렵 ..
교수님께서 기존 웹, 모바일 서비스와 연동되는 채팅 기능을 추가 개발해달함
그리고 몇가지 요구 사항을 말씀하시는데...
이렇게 2주간 시간을 잡고 개발을 시작하였다...
3. 채팅 서버 요구 사항
• 단체 채팅 기능
• 메시지 미수신자 확인
• 실시간 현재 접속중인 사람 확인
• 대화방 초대 기능
• 푸시(GCM/APNS) 메시지 전송
• 웹, 모바일(하이브리드앱) 지원
• 방나가기 기능
4. 짱구 굴리기…
소켓 서버 개발이 처음.. 검색 또 검색 ...
1) 기술 스팩 결정
2) 문서 둘러보기
3) 패킷 전송 프로세스 결정 (방참여, 메시지 전송, 등)
4) 프로젝트 구성
5) DB 구성
6) 각 기능 구현
5. 서버 기술 스팩
• 서버 : NodeJS (6.x)
• 소켓 Lib : Socket.io (1.7.x)
• 프레임워크 : express(4.x)
• DB : mysql
6. 클라이언트 기술 스팩
• 웹
• Jquery
• Socket.io
• 모바일(하이브리드 앱)
• angularJS
• Socket.io
7. Socket.IO 문서 둘러보기1
• 이벤트 리슨 & 발생
응답을 콜백 함수로 할 땐
emit하는 곳에서 3번째 인자값으로
콜백함수 명시 해야됨 ( 2번째 emit 참고)
8. Socket.IO 문서 둘러보기2
• 대화방 == 채널 ( 룸 ) 사용
대화방1
대화방2
소켓 서버
• 소켓을 묶어서 채널(룸)을 생성 함
• 해당 채널(룸)은 독립된 공간
• 클라이언트 접속 시 해당 채널(룸)으로 조인
• 접속 종료시 해당 채널(룸)을 나간 후 소켓연결
종료
9. Socket.IO 문서 둘러보기3
• 채팅 서버 생성
• 채팅 방 관련
• 메시지 전송
이 부분은 각자 맞게 수정
//보내는 사람 포함
//보내는 사람 제외
10. 소켓 패킷 프로세스 1
(방 접속)
서버클라이언트
-소켓 연결된 상태-
1.상대ID
-> 방 존재 검사
-> 없으면 생성 있으면 기존방코드
1.방코드
-> 검증
2.메시지 읽음 처리
3.최근 메시지 & 구성원 목록 가져옴
4.소켓 룸에 등록
5.모든 메시지 읽음 정보 가져옴
메시지 읽음 정보 ->
다음장에서 보충 설명
*모든 응답,요청은 JSON형식
11. 소켓 패킷 프로세스 2
(메시지 읽음)
서버클라이언트A
-A는 먼저 방에 접속된 상태-
for(메시지 목록){
if(메시지 번호 같음)
읽음 숫자 변경
}
클라이언트B
프로세스 1번과 같은 동작 후
12. 소켓 패킷 프로세스 3
(메시지 전송)
서버클라이언트A
1.방에 접속 중인 사람 검사
2.메시지 저장 (내용,..읽음사람)
3.해당 방에 메시지 전송
4.응답으로 메시지 번호(DB의 PK번호)
+ 메시지 내용 + 시간, 등..
클라이언트B
-소켓 연결된 상태-
13. 서버 프로젝트 구성
DB 엑세스
DB 접속 정보
비지니스 로직
푸시 관련 모듈
메인파일..(거의 컨트롤러ㅎ)
14. DB 구성
채팅방 테이블
room : 채팅방 UUID
id : 참여자
start_num : 채팅방에서 시작 메시지
( 채팅방 중간에 초대된 경우 start_num에 시작 메시지 번호 입력 )
메시지 테이블
num : 메시지 고유 ID
flag : 메시지 읽은 사람ID (id1,id2,id3 형식으로 저장)
*그 외 유저 table은 각자 맞게 구성
18. 기능 구현4
(비동기 처리)
• 비동기 처리 & 콜백 지옥 탈출을 위한 필수 모듈
• Bluebird 모듈 설치
npm install --save bluebird
Promise : 약속 생성
Resolve : 약속 지킴
Reject : 약속 못 지킴
Fn().then(콜백) 형식으로 받아서 사용 함
그 외 약속 배열을 받아 처리하는 all, 등이있음
19. 클라이언트 구현
(삽질 했던 것)
• ionic 환경에서 삽질했던 것
socket연결(성공) -> 종료 -> 연결(실패)
해결 방법 : socket.io lib 업데이트
socket연결을 반복적으로 연결 끊기 했을 때 이벤트(socket.on())가 중복으로 호출됨
해결 방법 : connect() 전에 socket.removeListener(); 호출
scope변경 값이 뷰에 적용 안됨
해결 방법 : socket이벤트 동기와 scope 업데이트 동기가 안맞는듯
Scope를 강제로 업데이트
apply를 그냥 호출하면 충돌이 날 수 있으니 주기를 검사 후 호출
20. 전체 코드는 Git Hub에…
• https://github.com/parkjungwoong/Node-
based-chat-server