summaryrefslogtreecommitdiff
path: root/test/files/detach-run/basic/Client.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2010-11-17 12:26:13 +0000
committermichelou <michelou@epfl.ch>2010-11-17 12:26:13 +0000
commitc09f6173e96ec741c9b38edfee969ae8c6b74d4e (patch)
tree1f06579f72afa12092acd0b5bbb7c678291cf619 /test/files/detach-run/basic/Client.scala
parent363a1456f671323b35dcacf2c8b8eb39180b8a53 (diff)
downloadscala-c09f6173e96ec741c9b38edfee969ae8c6b74d4e.tar.gz
scala-c09f6173e96ec741c9b38edfee969ae8c6b74d4e.tar.bz2
scala-c09f6173e96ec741c9b38edfee969ae8c6b74d4e.zip
updates Scala examples, added detach plugin
Diffstat (limited to 'test/files/detach-run/basic/Client.scala')
-rw-r--r--test/files/detach-run/basic/Client.scala44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/files/detach-run/basic/Client.scala b/test/files/detach-run/basic/Client.scala
new file mode 100644
index 0000000000..d3f159fd40
--- /dev/null
+++ b/test/files/detach-run/basic/Client.scala
@@ -0,0 +1,44 @@
+import java.net._, Thread._, ClientHelper._
+import scala.remoting._, Debug._
+
+object Foo {
+ def trace(s: String) { info("[Foo.trace] "+s)}
+}
+object Client {
+ val yInstVal: Int = 10
+ var yInstVar: Int = 99
+ object Bar {
+ def trace(s: String) { info("[Bar.trace] "+s) }
+ }
+ def main(args: Array[String]) {
+ init(args)
+ val server = new Channel(host, port)
+ val zLocVal: Int = 1000
+ var zLocVar: Int = 9998
+ server ! detach(
+ (x: Int) => {
+ println("yInstVal = "+yInstVal)
+ this.trace("yInstVar = "+yInstVar)
+ Bar.trace("zLocVal = "+zLocVal)
+ Foo.trace("zLocVar = "+zLocVar)
+ zLocVar += 2
+ System.out.println("zLocVal = "+zLocVal)
+ Debug.info("zLocVar = "+zLocVar)
+ x + yInstVal + yInstVar + zLocVal + zLocVar
+ })
+ val result = server.receiveInt
+ println("result received: " + result)
+ }
+ private def trace(s: String) { info("[Client.trace] "+s) }
+}
+
+object ClientHelper {
+ private var _host = "127.0.0.1"
+ private var _port = 8888
+ def host = _host
+ def port = _port
+ def init(args: Array[String]) {
+ try { _host = args(0) } catch { case _ => }
+ try { _port = args(1).toInt } catch { case _ => }
+ }
+}