├── bin
├── html
│ ├── xx
│ └── index.html
└── conf
│ ├── system.yml
│ ├── worker.yml
│ ├── log.yml
│ └── server.yml
├── .gitmodules
├── move.sh
├── Makefile
├── chat
├── my_module.h
├── protocol.h
├── resource_servlet.h
├── chat_servlet.h
├── protocol.cc
├── resource_servlet.cc
├── my_module.cc
└── chat_servlet.cc
├── .gitignore
├── README.md
└── CMakeLists.txt
/bin/html/xx:
--------------------------------------------------------------------------------
1 | adsofijzxv
2 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "sylar"]
2 | path = sylar
3 | url = https://github.com/sylar-yin/sylar.git
4 |
--------------------------------------------------------------------------------
/bin/conf/system.yml:
--------------------------------------------------------------------------------
1 | server:
2 | work_path: /apps/work/chat_room
3 | pid_file: chat_room.pid
4 |
--------------------------------------------------------------------------------
/bin/conf/worker.yml:
--------------------------------------------------------------------------------
1 | workers:
2 | io:
3 | thread_num: 4
4 | accept:
5 | thread_num: 1
6 |
--------------------------------------------------------------------------------
/move.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ ! -d bin/module ]
4 | then
5 | mkdir bin/module
6 | else
7 | unlink bin/chat_room
8 | unlink bin/module/libchat_room.so
9 | fi
10 |
11 | cp sylar/bin/sylar bin/chat_room
12 | cp lib/libchat_room.so bin/module/
13 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: xx
2 |
3 | xx:
4 | if [ -d "build" ]; then \
5 | cd build && make; \
6 | else \
7 | mkdir build; \
8 | cd build && cmake ..; \
9 | fi
10 |
11 | %:
12 | if [ -d "build" ]; then \
13 | cd build && make $@; \
14 | else \
15 | mkdir build; \
16 | cd build && cmake ..; \
17 | fi
18 |
--------------------------------------------------------------------------------
/chat/my_module.h:
--------------------------------------------------------------------------------
1 | #include "sylar/module.h"
2 |
3 | namespace chat {
4 |
5 | class MyModule : public sylar::Module {
6 | public:
7 | typedef std::shared_ptr ptr;
8 | MyModule();
9 | bool onLoad() override;
10 | bool onUnload() override;
11 | bool onServerReady() override;
12 | bool onServerUp() override;
13 | };
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | tags
2 | *.o
3 | *.sub
4 | *.guess
5 | ltmain.sh
6 | *.la
7 | *.a
8 | .deps
9 | .dirstamp
10 | .libs
11 | *.lo
12 | *.pb.h
13 | *.pb.cc
14 | *.rl.cc
15 | aclocal.m4
16 | autom4te.cache
17 | config.h.in
18 | config.log
19 | config.status
20 | configure
21 | config.h.in~
22 | install-sh
23 | libtool
24 | Makefile
25 | Makefile.in
26 | missing
27 | stamp-h1
28 | *.pc
29 | depcomp
30 | *.xcodeproj
31 |
--------------------------------------------------------------------------------
/bin/conf/log.yml:
--------------------------------------------------------------------------------
1 | logs:
2 | - name: root
3 | level: info
4 | appenders:
5 | - type: FileLogAppender
6 | file: /apps/logs/chat_room/root.txt
7 | - type: StdoutLogAppender
8 | - name: system
9 | level: info
10 | appenders:
11 | - type: FileLogAppender
12 | file: /apps/logs/chat_room/system.txt
13 | - type: StdoutLogAppender
14 |
--------------------------------------------------------------------------------
/bin/conf/server.yml:
--------------------------------------------------------------------------------
1 | servers:
2 | - address: ["0.0.0.0:8090", "127.0.0.1:8091", "/tmp/test.sock"]
3 | keepalive: 1
4 | timeout: 1000
5 | name: sylar/1.1
6 | accept_worker: accept
7 | io_worker: io
8 | process_worker: io
9 | type: http
10 | - address: ["0.0.0.0:8072", "localhost:8071"]
11 | keepalive: 1
12 | timeout: 1000
13 | name: sylar/2.1
14 | accept_worker: accept
15 | io_worker: io
16 | process_worker: io
17 | type: ws
18 |
--------------------------------------------------------------------------------
/chat/protocol.h:
--------------------------------------------------------------------------------
1 | #ifndef __CHAT_PROTOCOL_H__
2 | #define __CHAT_PROTOCOL_H__
3 |
4 | #include
5 | #include