diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..41882c1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+*~
+*#*
+target
+project/boot
+workspace
+.history
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..a7ff367
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+actors
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..a1b41c5
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..3572571
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..e206d70
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f631321
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,27 @@
+
+
+
+ http://www.w3.org/1999/xhtml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..684f749
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.idea/scala_settings.xml b/.idea/scala_settings.xml
new file mode 100644
index 0000000..0c2fa77
--- /dev/null
+++ b/.idea/scala_settings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000..922003b
--- /dev/null
+++ b/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..3b00020
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,125 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..def6a6a
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..488cfdf
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,431 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ localhost
+ 5050
+
+
+
+
+
+
+ 1342778839534
+ 1342778839534
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+ Scala 2.9.2 lib
+
+
+
+
+
+
+
+
+
+
+
+ 1.6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.sbt b/build.sbt
new file mode 100644
index 0000000..d62953d
--- /dev/null
+++ b/build.sbt
@@ -0,0 +1,5 @@
+name := "Chat with Actors"
+
+version := "1.0"
+
+scalaVersion := "2.9.1"
\ No newline at end of file
diff --git a/src/main/scala/ChatMessages.scala b/src/main/scala/ChatMessages.scala
new file mode 100644
index 0000000..fb7710a
--- /dev/null
+++ b/src/main/scala/ChatMessages.scala
@@ -0,0 +1,3 @@
+sealed trait Message
+case class ChatMessage(msg: String) extends Message
+case class ChatInfo(inf: String) extends Message
\ No newline at end of file
diff --git a/src/main/scala/Client.scala b/src/main/scala/Client.scala
new file mode 100644
index 0000000..16a1010
--- /dev/null
+++ b/src/main/scala/Client.scala
@@ -0,0 +1,64 @@
+import scala.actors.Actor
+import scala.actors.Actor._
+import scala.actors.remote.RemoteActor
+import scala.actors.remote.RemoteActor._
+import scala.actors.remote.Node
+
+object ChatClient{
+
+ /*
+ *
+ * Argument one is host name
+ * Argument two is port
+ * Argument 3 is client name
+ */
+ def main(args:Array[String]){
+ val peer = Node("localhost", 2552)
+ val client = new ClientActor(peer);
+ client.setId("nana")
+ client.start()
+ }
+
+}
+
+
+class ClientActor(peer:Node) extends Actor{
+
+ var id:String = "client"
+ def setId(id: String) = {this.id = id}
+ def getId = this.id
+
+ def act() {
+ alive(2552)//@TODO: make this a param
+ register('ChatClient, self)
+ val server = select(peer, 'ChatServer)
+ link(server)
+
+ while (true){
+ print(">> ")
+ val cinput = readLine()
+ if(cinput != null){
+ var mymessage = cinput
+ server ! mymessage
+
+ receive {
+ case (x: String) => {
+ if(x == "exit"){
+ println("Closing thread...")
+ unlink(server)
+ exit()
+ }
+ println("From Server: "+x)
+ }
+
+ case ChatInfo(x:String) => {
+ println("INFO: "+x)
+ }
+ case _ => println("Server received invalid message format")
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/src/main/scala/Server.scala b/src/main/scala/Server.scala
new file mode 100644
index 0000000..1f855d8
--- /dev/null
+++ b/src/main/scala/Server.scala
@@ -0,0 +1,51 @@
+import scala.actors.Actor
+import scala.actors.Actor._
+import scala.actors.remote.RemoteActor
+import scala.actors.remote.RemoteActor._
+import scala.actors.remote.Node
+import collection.mutable.Set
+
+
+
+object ChatServer extends App{
+ val server = new ServerActor();
+ server.start()
+
+}
+
+class ServerActor() extends Actor{
+
+ val connectedClients:Set[String] = Set()
+
+ def getClients = { this.connectedClients }
+
+ def registerClient(client: ClientActor) = {
+ if(!this.connectedClients.contains(client.getId)){
+ this.connectedClients += client.getId
+ println(this.connectedClients)
+ }else{
+ client ! "This client name is not unique"
+ }
+ }
+
+ def act() {
+
+ alive(2552)//@TODO: make this a param
+ register('ChatServer, self)
+ println("Server is ready")
+ while(true) {
+ receive {
+ case x: String => {
+ if(x == "exit"){
+ println("Recieved exit request, remove client from connection")
+ sender ! "exit"
+ }
+
+ println("Client Message Received: "+x+" acknowledged")
+ sender ! new ChatInfo("ACK")
+ }
+ case _ => println("Server received invalid message format")
+ }
+ }
+ }
+}