I came across this really nice Scala code while researching XMPP for the .Net project we're working on:
object Main {
def main(args: Array[String]) :Unit = {
new XMPPComponent(
new ComponentConfig() {
def secret() : String = { "secret.goes.here" }
def server() : String = { "communitivity.com" }
def subdomain() : String = { "weather" }
def name() : String = { "US Weather" }
def description() : String = { "Weather component that also supported SPARQL/XMPP" }
},
actor {
loop {
react {
case (pkt:Packet, out : Actor) =>
Console.println("Received packet...\n"+pkt.toXML)
pkt match {
case message:Message =>
val reply = new Message()
reply.setTo(message.getFrom())
reply.setFrom(message.getTo())
reply.setType(message.getType())
reply.setThread(message.getThread())
reply.setBody("Received '"+message.getBody()+"', tyvm")
out ! reply
case _ =>
Console.println("Received something other than Message")
}
case _ =>
Console.println("Received something other than (Packet, actor)")
}
}
}
).start
}
}
(This was taken from http://github.com/Communitivity/MinimalScalaXMPPComponent/blob/master/src/org/communitivity/echoxmpp/Main.scala )
Actor and template compatible stuff looks like a really good way to write components in a scalable way. I have not been able to find any C # actor libraries that look mature, and exploring Axum seems redundant.
What would be the right way to attack this in C #? (of course, ignoring the specific XMPP code - I'm more interested in what the version of C # actors and template matching will look like).