Giter VIP home page Giter VIP logo

chatserver's Introduction

ChatServer

이 프로그램의 기능

Netty 을 기반으로 TCP 프로토콜을 이용하고 데이터는 JSON 을 이용한 싱글 서버용 채팅 서버입니다. Spring Boot 에서 작동하기 때문에 Injection 을 이용할 수 있습니다.

이 프로그램을 만들게 된 동기

이 프로그램은 Netty 기반 UDT 프로토콜을 이용하고 데이터는 Protobuf 을 이용한 멀티 서버용 채팅 서버를 개발하면서 터득한 몇 가지 노하우를 공개하기 위해 만든 일종의 예제입니다.

개발환경

IntelliJ 에서 개발하였습니다.

라이센스

The Artistic License 2.0 입니다. 제약이 많은 라이센스이니 주의하여 주십시오.

간단한 테스트

git clone 을 한 뒤 maven 으로 package 를 만들어서 jar 파일을 실행하거나, IDE 에서 Spring boot 로 Run 하면 됩니다. (스프링 부트를 잘 모르시는 분을 위해 설명드리면) 이 때 실행되는 경로(Working Directory)는 프로젝트(모듈) 디렉토리로 설정해야 config/ 의 application.yml 설정 파일을 읽습니다.

서비스 실행 뒤, 두 개의 클라이언트(윈도우즈 내장 telnet 으로도 충분합니다)로 접속 후 아래와 같이 로그인-메세지 발송을 테스트 해봅니다.

1번 클라이언트

> telnet localhost 9812

{"method": "login", "userId": "test1", "password": "123456"}

2번 클라이언트

> telnet localhost 9812

{"method": "login", "userId": "test2", "password": "098765"}
{"method": "send", "content": "Send Message"}

채팅 룸을 만들거나 메세지를 보내는 것은 아래와 같이 룸 생성-메세지 발송을 테스트 해봅니다.

1번 클라이언트

{"method": "create_room"}

2번 클라이언트

{"method": "enter_room", "roomId": "(1번 클라이언트에서 응답으로 온 roomId)"}
{"method": "send_room", "content": "Test Message"}

채팅룸에서 나가는 것은 아래와 같은 명령을 이용합니다.

{"method": "exit_room"}

chatserver's People

Contributors

zepinos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatserver's Issues

안녕하세요 올려주신 채팅 서버 테스트중 질문입니다

안녕하세요 netty로 채팅 서버 구현하려고 올려주신 예제로 테스트 해보고 있는데
올려주신 것처럼 클라이언트에서 메세지를 보내면 오류가 나더라구요

[id: 0xb312e5fe, L:/127.0.0.1:9812 - R:/127.0.0.1:51017] RECEIVED,

DefaultFullHttpRequest(decodeResult: failure(java.lang.IllegalArgumentException: invalid version format: "USERID": "TEST1", "PASSWORD": "123456"}), version: HTTP/1.0, content: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 0, cap: 0))
GET /bad-request HTTP/1.0, 0B

2018-01-16 13:15:32.960 INFO 17284 --- [ntLoopGroup-3-1] io.netty.handler.logging.LoggingHandler : [id: 0xb312e5fe, L:/127.0.0.1:9812 - R:/127.0.0.1:51017] RECEIVED, DefaultFullHttpRequest(decodeResult: failure(java.lang.IllegalArgumentException: invalid version format: "USERID": "TEST1", "PASSWORD": "123456"}), version: HTTP/1.0, content: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 0, cap: 0))

이런식의 오류가 발생합니다

혹시 해결방법을 알려주실 수 있을지요

------ 해결되었습니다 TCP로 세팅하니 해결되었네요.^^ 예제 감사합니다

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.