Sample chat application built with netcore, F#, Akka.net and Fable.
npm i yarn -g)
fake build -- start
fake build -- clean build
fake build -- restore
fake build -- build-- just build, no restore
Alternatively follow the instruction below:
E2e tests are based on canopy and webdriver so currently I know it runs on Windows. I have no idea how to run in non-windows environment.
fake build -- test
or follow these steps:
Tests should be run on clean server, but after server became persistent this condition is usually not met (consider cleaning the src/Server/CHAT_DATA folder ny hands).
FsChat supports both permanent users, authorized via goodle or github account, and anonymous ones, those who provide only nickname.
In order to support the google/fb authentication scenario, fill in the client/secret in the CHAT_DATA/suave.oauth.config file. In case you do not see this file, run the server once and the file will be created automatically.
FsChat backend is based on Akka.Streams. The entry point is a
GroupChatFlow module which implements the actor, serving group chat.
UserSessionFlow defines the flows for user and control messages, brings everything together and exposes flow for user session.
AboutFlow is an example of implementing channel with specific purpose, other than chatting
ChatServer is an actor which purpose is to keep the channel list. It's responsible for creating/dropping the channels.
UserStore is an actor which purpose is to know all users logged in. It supposed to be made persistent but it does not work for some reason (I created issue).
SocketFlow implements a flow decorating the server-side web socket.
Akkling is an unofficial Akka.NET API for F#. It's not just wrapper around Akka.NET API, but introduces some cool concepts such as Effects, typed actors and many more.
Client is written on F# with the help of Fable and Elmish (library?, framework?). Fable is absolutely mature technology, Elmish is just great.
After client is authenticated all communication between client and server is carried via WebSockets. The protocol is defined in
src/Shared/ChatProtocol.fs file which is shared between client and server projects.
Server implementation demonstrates using Akka Persistance to restore server state after restart. It's based on event sourcing. However the server destroys the channels when all users are gone. So all channels created by users are non-permanent and will unlikely be restored after restart.