- functions have been implemented:
- Specify address of server being connected to.
- Receive messages sent by other connected clients.
- Send messages to the server.
- Save chat messages into a database
- Rejoining a chat will reload the last hour's worth of messages
- Login by input user name and password (Authentication system)
- partially done
- Write Unit Tests
- have not been implmented yet
- Write Integration Tests
build server and clint
make build
print info log in server
export GRPC_GO_LOG_SEVERITY_LEVEL=info
Join a chatroom using the command (default address: 127.0.0.1:8080)
bin/client --address 127.0.0.1:8080 join
DB now have users:
- name:"admin" pw:"password"
- name:"test" pw:"testpassword"
You can also specific the user (default: Anonymous)
bin/client --address 127.0.0.1:8080 join --name admin --password password
Start a chatroom server using the command
bin/server -port 8080
- Specify port for accepting incoming messages.
- Accept messages from clients and send them to other connected clients.
client1 : anonymous user
$ bin/client --address 127.0.0.1:8080 join
msg1
2021-02-07 03:33:37.8917699 +0000 UTC (Anonymous) : msg1
msg2
2021-02-07 03:33:40.9342148 +0000 UTC (Anonymous) : msg2
client2 : admin
$ ./client join --name admin --password password
2021-02-07 03:33:37.8917699 +0000 UTC (Anonymous) : msg1
2021-02-07 03:33:40.9342148 +0000 UTC (Anonymous) : msg2
admin msg1
2021-02-07 03:33:59.6100702 +0000 UTC (admin) : admin msg1
admin msg2
2021-02-07 03:34:02.5832109 +0000 UTC (admin) : admin msg2
clien3 : test
$ ./client join --name test --password testpassword
2021-02-07 03:33:37.8917699 +0000 UTC (Anonymous) : msg1
2021-02-07 03:33:40.9342148 +0000 UTC (Anonymous) : msg2
2021-02-07 03:33:59.6100702 +0000 UTC (admin) : admin msg1
2021-02-07 03:34:02.5832109 +0000 UTC (admin) : admin msg2
test user 1 msg1
2021-02-07 03:34:10.6042247 +0000 UTC (test) : test user 1 msg1
test user 1 msg2
2021-02-07 03:34:13.5351272 +0000 UTC (test) : test user 1 msg2
server: set GRPC_GO_LOG_SEVERITY_LEVEL=info
$ bin/server -port 8080
INFO: 2021/02/07 11:33:23 listening port: 8080
INFO: 2021/02/07 11:33:25 conn id: 54bc47a5b784af2dfa92f291b24ac48896c71cbf15e55984efd825ff2ebb39e1 connected
INFO: 2021/02/07 11:33:37 2021-02-07 03:33:37.8917699 +0000 UTC (Anonymous) : msg1
INFO: 2021/02/07 11:33:40 2021-02-07 03:33:40.9342148 +0000 UTC (Anonymous) : msg2
INFO: 2021/02/07 11:33:47 conn id: c5c5a327fe96f19a555ff8e9783846efc7eed719bf89d9d7c28b83b0050e0113 connected
INFO: 2021/02/07 11:33:59 2021-02-07 03:33:59.6100702 +0000 UTC (admin) : admin msg1
INFO: 2021/02/07 11:34:02 2021-02-07 03:34:02.5832109 +0000 UTC (admin) : admin msg2
INFO: 2021/02/07 11:34:05 conn id: a7eda006cade9a912e8af038d620bf91f467f233ff2e27a2930e2ccd89f36407 connected
INFO: 2021/02/07 11:34:10 2021-02-07 03:34:10.6042247 +0000 UTC (test) : test user 1 msg1
INFO: 2021/02/07 11:34:13 2021-02-07 03:34:13.5351272 +0000 UTC (test) : test user 1 msg2