Comments (17)
installing dependencies
npm i --save @nestjs/websockets @nestjs/platform-socket.io
creating a gateway module
nest -g module gateway
from nestj.
Postman의 WebSocket Request 이용하기
이 곳에서 내 로컬호스트와 포트 값을 설정하고 맨 처음 리스닝을 하는 코드와 잘 연결되는지 확인한다.
이벤트 네임에는 'newMessage' 를 넣었다.
그리고 New Message 라고 써있는 Context 에 아무 내용을 작성하고 전달하면
지금 내 서버에 컨솔에 전달된 것을 알 수가 있다.
from nestj.
JSON 타입으로 바꿔주고
{
"msg" : "Hello, World"
}
뭔가 irc 에 메시지 클래스와 비슷한 느낌
from nestj.
Sending data part,
from nestj.
Define a property called server, we're gonna type annotate the Server
that Decorator attaches the native websocket server to a given property which's going to be this property
from nestj.
Created another connection to the ws server, gonna go over to this event tab, specify the name of the event
that could treat them to be separated. 'New Message' send, receive to client that are listening to with the specific, then consume that Message.
from nestj.
여태까지 개요, 포스트맨을 통해서 socket I/O Request 를 만들었고
해당 서버에 특정 이벤트를 보내면, 서버에 구현된 이벤트 처리를 통해 특정 리스닝 클라이언트에게 메시지를 전달해준다.
그게 연결되어 해당 리스닝을 하고 있는 상태여야만 전달될 수 있다.
from nestj.
socket I/O client Library 설치
npm i socket.io-client
from nestj.
어. 끝났다.
제로초 Nest.js + Socket.io(EventsGateway) 강좌 시작
from nestj.
저번에 nest -g module websocket 이 안됐는데 다른 예제를 보니
nest g mo websockets
로 대신 하면 되더라
from nestj.
여태까지 배웠던 것들 프론트와 피어 리뷰
MVC 디자인 패턴
계층형 아키텍쳐
클라이언트가 요청 시 서버가 반응하는 과정
의존성 주입
모듈 단위, 엔티티, 데이터베이스
from nestj.
react 라이브러리 설치
npm i socket.io-client @emotion/styled className
이걸 6ew 안에 설치한다.
from nestj.
서버와 클라이언트 연결 성공,
이제 회원가입해서 유저 생성,
그 유저 네임을 가져다가 채팅에 데이터 바인딩을 할 수 있도록 설계
from nestj.
왜 모듈이 못 찾는지 알았음
from nestj.
스키마를 직접 생성했고, 이전에 유저 생성할 때 받는 파라미터들을 요구하는데 이것들을 분리해놓을 예정
from nestj.
자주하는 실수, 모듈에 자꾸 레퍼지토리 빼먹음
from nestj.
socket.io - namespace 사용하기
from nestj.
Related Issues (13)
- [feat] : NestJS install, start HOT 2
- [feat] 게시판 CRUD : R HOT 5
- [feat] 게시판 CRUD : C, D, U HOT 6
- [feat] : TypeORM HOT 1
- [feat] : Pipe 로 전송과 검증을 하기 HOT 6
- [Feat] : Entity 와 Database를 이용한 CRUD HOT 13
- [Feat] : User HOT 22
- [Feat] : Auth HOT 6
- [Feat] : Logging HOT 3
- [Feat] : configuration HOT 2
- socket.io HOT 3
- 오늘까지 로그인 데모 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestj.