Created
November 9, 2015 13:35
-
-
Save monkieboy/890c68fbcfd6e082b398 to your computer and use it in GitHub Desktop.
Akka F#
This file contains 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
namespace AkkaTypesCS | |
{ | |
public class GreetCs | |
{ | |
public GreetCs(string who) | |
{ | |
Who = who; | |
} | |
public string Who { get; set; } | |
} | |
} |
This file contains 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
module AkkaTypes | |
//type Greet = | |
// { Who: string } | |
type Greet(who:string) = | |
member x.Who = who |
This file contains 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
open Akka.Actor | |
open Akka.Configuration | |
open System | |
open AkkaConsoleApplication | |
open AkkaTypesCS | |
[<EntryPoint>] | |
let main argv = | |
let config = ConfigurationFactory.ParseString(@" | |
akka { | |
actor { | |
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote"" | |
} | |
remote { | |
helios.tcp { | |
port = 0 # bound to a dynamic port assigned by the OS | |
hostname = localhost | |
} | |
} | |
}") | |
let greetee = Console.ReadLine(); | |
use system = ActorSystem.Create("MyClient", config) | |
let greeter = system.ActorSelection("akka.tcp://MyServer@localhost:8081/user/greeter") | |
let msg = GreetCs(greetee) | |
greeter.Tell msg | |
Console.ReadLine() |> ignore | |
0 |
This file contains 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
module AkkaConsoleApplication | |
open Akka.Actor; | |
open Akka.Configuration; | |
open System; | |
open AkkaTypesCS | |
type GreetingActor() as g = | |
inherit ReceiveActor() | |
do g.Receive<_>(fun (greet:GreetCs) -> printfn "Hello %s" greet.Who) | |
[<EntryPoint>] | |
let main argv = | |
let config = ConfigurationFactory.ParseString(@" | |
akka { | |
actor { | |
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote"" | |
} | |
remote { | |
helios.tcp { | |
port = 8081 | |
hostname = localhost | |
} | |
} | |
} | |
") | |
let system = ActorSystem.Create("MyServer", config) | |
let greeter = system.ActorOf<GreetingActor> "greeter" | |
let name = System.Console.ReadLine() | |
System.Console.ReadLine() |> ignore | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You totally stole that from the repo!