A simple chat server using Akka and Scala.
1. First Version Commit
- actor ChatServer: Join and Leave the chat group, Broadcast an incoming message to all current chat members
- actor ChatClient: Join the chat group, Broadcast a first intro message
- ChatApp: first running App with three ChatClients
Clone this repository, cd
into it and start sbt. Then execute run
and choose org.sandbox.chat.http.HttpChatApp
:
akka-chat$ sbt
[info] ...
akka-chat$ run
[info] ...
Multiple main classes detected, select one to run:
[1] org.sandbox.chat.http.HttpChatApp
[2] org.sandbox.chat.ChatApp
Enter number: 1
[info] ...
Open a second console and start an SSE session on port 9000
:
~$ curl -X GET http://localhost:9000
Open a third console and send chat client commands to the server on port 8080
.
You will see the respective commands as SSEs sent to the second console:
~$ curl -X GET http://localhost:8080/join/Achim
~$ curl -X POST --data 'one line
another line' http://localhost:8080/contrib/Achim
~$ curl -X GET http://localhost:8080/join/Michael
~$ curl -X PUT --data 'one line again
and yet another line' http://localhost:8080/contrib/Michael
~$ curl -X GET http://localhost:8080/poll/Achim
~$ curl -X GET http://localhost:8080/leave/Michael
~$ curl -X GET http://localhost:8080/shutdown/shutdown
The Akka HTTP endpoints are defined in ChatRoutes.
Details: https://snap-ci.com/fpinscala-muc/akka-chat/branch/master