Created
June 1, 2016 16:48
-
-
Save object/2512c85c96369011b69e53a3b3d06102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let sftpActor (clientFactory : IClientFactory) (mailbox: Actor<_>) = | |
| let rec disconnected () = | |
| actor { | |
| let! message = mailbox.Receive () | |
| match message with | |
| | Connect -> | |
| let connection = clientFactory.CreateSftpClient() | |
| connection.Connect() | |
| return! connected (connection) | |
| | _ -> | |
| cprintfn ConsoleColor.Yellow "Sftp: invalid operation in disconnected state: %A" message | |
| return! disconnected () | |
| } | |
| and connected (connection) = | |
| actor { | |
| let! message = mailbox.Receive () | |
| match message with | |
| | Disconnect -> | |
| connection.Disconnect() | |
| connection.Dispose() | |
| return! disconnected () | |
| | _ -> | |
| cprintfn ConsoleColor.Yellow "Sftp: invalid operation in connected state: %A" message | |
| return! connected (connection) | |
| } | |
| disconnected () | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment