This is a character generator.Character is the one you image what you should be. It stay in your pc or mobile locally and use basic service from network.
The first function is chatroom based on a simple tcp framework.
Use new protocol, eg. chatroom.send|msg:haha
2015-11-6 21:41
Use the new feature of hazel: Delegation
Use Message to send msg to clients, including boardcast.
More details seen in hazel
You should install Go first.
- Ubuntu & Debian based Linux
sudo apt-get install go-langThis project is based on hazel and utils. You can get it by the command:
go get github.com/sctlee/hazel
go get github.com/sctlee/utilsBe careful, You may want to cd /path/to/example and export GOPATH=$(pwd):$GOPATH, the exec the above commands.
If you have installed Go and dependences, you can easily install the example using the following commands.
cd /path/to/example
export GOPATH=$(pwd):$GOPATH
go install exampleIf you have installed the example successfully, you will see the binary file example in
/path/to/example/bin, you can use it as the following:
./bin/example server
# open a new bash
./bin/example client
> chatroom.join|ctName:1
> chatroom.send|msg:helloChatroom feature has three command: list, join, send
> chatroom.list|
> chatroom.join|ctName:1
> chatroom.send|msg:hello
User feature has three command: login, logout, setName
> user.login|username:***;password:***
> user.setName|name:hc
> user.logout|
Because db has not been supported, user's name is fake. It means you can't sign up and the name you set can't be saved.
#Docker Deployment If you have not known docker, learn it.
Pull two images, postgres and redis
docker pull postgres
docker pull redisIf you use DaoCloud Tools, you can do this:
dao pull postgres
dao pull redisIt will be extremely fast! in TianChao.
Build hazel images, hazel for (hazel)[github.com/sctlee/hazel], hazel-server for (hazel_example)(github.com/sctlee/hazel_example)
docker build -t hazel:1.1 .
docker build -t hazel-server:1.1 .!!You should build the image after modifying the config.yml.example.
Then run three containers by three command in bash respectively.
docker run --rm --name hazel_postgres -v /Users/Secret/Codes/Projects/hazel_example/test/posgres/:/docker-entrypoint-initdb.d -e POSTGRES_USER=Secret postgres
docker run --rm --name hazel_redis redis
docker run --rm -it -p 8080:9000 --link hazel_postgres:pg --link hazel_redis:rd hazel-server:1.1What you should notice is the flag -v, I copy the sql scripts to postgresql for init the database. See the postgres for more details.
Finially, run the hazel.
example serverYou can connect the server in your host computer
example client 192.168.99.100:8080