From 910ac21b22c3a492b3d26c5027b19b6c194b2d76 Mon Sep 17 00:00:00 2001 From: babaq Date: Sat, 17 Oct 2009 15:27:37 +0800 Subject: [PATCH] Basic Server Script --- Release/BasicServer.fsx | 55 ++++++++++++++++++++++++++++++++++++++++ StiLib.suo | Bin 54272 -> 59920 bytes 2 files changed, 55 insertions(+) create mode 100644 Release/BasicServer.fsx diff --git a/Release/BasicServer.fsx b/Release/BasicServer.fsx new file mode 100644 index 0000000..75db784 --- /dev/null +++ b/Release/BasicServer.fsx @@ -0,0 +1,55 @@ +// F# Script File : BasicServer.fsx +// +// StiLib Basic Server In F# Scripting +// +// Copyright (c) 2009-10-17 Zhang Li + +#r @"StiLib.dll" +#r @"Microsoft.Xna.Framework.dll" +#r @"System.ServiceModel" + +open System +open System.Windows.Forms +open Microsoft.Xna.Framework.Graphics +open StiLib.Core +open StiLib.Vision +open System.ServiceModel +open System.ServiceModel.Description + +// Our Custom Experiment Server is inherited from StiLib.Core.ExService +[] +type MyEx = class + inherit ExService + // Our Stimulus + val mutable text: Text + val mutable grating: Grating + // Init Experiment + new() as this = + { inherit ExService(800, 600, 0, true, true); grating = null; text = null } + then + this.text <- new Text(this.GraphicsDevice, this.Services, this.SLConfig.["content"], "SegoeUI") + this.grating <- new Grating(this.GraphicsDevice, this.Services, this.SLConfig.["content"]) + // Override methods to custom your own experiment logic + override this.Draw() = + this.GraphicsDevice.Clear(Color.Gray) + if this.GO_OVER = true then + this.grating.Draw(this.GraphicsDevice) + else + this.text.Draw() +end + +let MyExperiment = new MyEx(Text = "BasicServer In F# Scripting") + +// Server Hosting +let Host = new ServiceHost(MyExperiment, new Uri("net.tcp://zhangli:8080/ExServer")) +Host.AddServiceEndpoint(typeof, new NetTcpBinding(SecurityMode.None), "") + +let mutable metabehavior = new ServiceMetadataBehavior() +metabehavior.HttpGetEnabled <- false +Host.Description.Behaviors.Add(metabehavior) +Host.AddServiceEndpoint(typeof, MetadataExchangeBindings.CreateMexTcpBinding(), "mex") + +// Run Host +Host.Open() +Application.Run(MyExperiment) +Host.Close \ No newline at end of file diff --git a/StiLib.suo b/StiLib.suo index 8ef11b5bef339321202b85d47f2c48cc0c6d7a11..04b86137b7f9505ee76418cc1ae725f79128d918 100644 GIT binary patch delta 3074 zcmb_edrXws6~EuiH!#QmpR+K$gdGHNeE@?FFrw}b437Z^MQ|TQ1es+WXL&uG^rmq#tU)`iN`-f>ZO|xnIqcJJ;+;4^v)NYea zzvMS_?z!ildtUe4>%XoZT~N>5Qi<;{#xSR{7~dvhacOCZ!%B1+p`2hN)DR%46Gaav z-coyub`!xRkJ0~eLMNe%aDvcH=ppnH`Uw35FJbZ0{(^wm8O5&U%s$_XK5;&VNyLvL zp#GD$5Y&no)Hnn??%ggxFiw>JrCBHBIB0$^!A{_o)Drd(`2KbDe~2QE`PrH;)G@4zCgb=rzU{O4dM%esUS@a`>a{u=tO+yZX9@dM zDj`NO%d0=D`g@H0TwfclttNq_uu#-SBA%+`p|oK^_5DQod3voN#DDf67Bx`>%r2}RdLQ8u$8md7fIt|Cqzjkgm@h}uDUD5jY_Rzb9xP(%_I;+7D{ z#)=>qHl!~t?PNS7r)c&ittd>{grhl+;m@f;h0}ns4Vw>rr=8eomd_fPn{r)lYpj1b zS@-KdCfv7way;(wXH|dcy_n5db$O$$5Q41+PjYq1`Rp*|zK3d{n;m1(w{LgN)csZ{ zUY@IrZk32EFW z9KQDQDf*o10x+G$UaX^PVFucY(?O;f^IikDAD`LVIkHD6Yg_gtX6>BG2 z&C2@i5v>#f3>=gcZfO0o&xRX%g}W+Rv3scmydnEg_U^v0|N7MbX8%f^>lA$R<% zvReMy(dF4h{N5>HY|kyBnj+%KsG~T$s2bWSBHipHRfUUaULW1;1kP+pLa_84ir=5X z;%S{=<7<*!BvnRerxWv`B1=b*%L;E}t+@*eO!T}_7`5Y_kxxSo7OiqHvRwjg*GMtyrzpAU>dL2f%KJ+=5b_rzg=)0T z>2BsWNeH^Eur>t)?kV&+jRY$iE?$GV+|@aNy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