Author: buildbot
Date: Wed Sep 21 21:34:51 2016
New Revision: 997946

Log:
Staging update by buildbot for thrift

Modified:
    websites/staging/thrift/trunk/content/   (props changed)
    websites/staging/thrift/trunk/content/about.html
    websites/staging/thrift/trunk/content/index.html
    websites/staging/thrift/trunk/content/lib/haxe.html
    websites/staging/thrift/trunk/content/test/ThriftTest.html
    websites/staging/thrift/trunk/content/test/keys.html
    websites/staging/thrift/trunk/content/tutorial/haxe.html
    websites/staging/thrift/trunk/content/tutorial/nodejs.html
    websites/staging/thrift/trunk/content/tutorial/py.html

Propchange: websites/staging/thrift/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Sep 21 21:34:51 2016
@@ -1 +1 @@
-1737163
+1761817

Modified: websites/staging/thrift/trunk/content/about.html
==============================================================================
--- websites/staging/thrift/trunk/content/about.html (original)
+++ websites/staging/thrift/trunk/content/about.html Wed Sep 21 21:34:51 2016
@@ -297,11 +297,6 @@ h2:hover > .headerlink, h3:hover > .head
         </tr>
 
         <tr class="">
-            <td class="company">Aereo</td>
-            <td class="website"><a 
href="http://www.aereo.com";>http://www.aereo.com</a></td>
-        </tr>
-
-        <tr class="">
             <td class="company">Cloudera</td>
             <td class="website"><a 
href="http://www.cloudera.com";>http://www.cloudera.com</a></td>
         </tr>

Modified: websites/staging/thrift/trunk/content/index.html
==============================================================================
--- websites/staging/thrift/trunk/content/index.html (original)
+++ websites/staging/thrift/trunk/content/index.html Wed Sep 21 21:34:51 2016
@@ -213,7 +213,7 @@ h2:hover > .headerlink, h3:hover > .head
     <span class="n">client</span><span class="o">.</span><span 
class="n">ping</span><span class="p">()</span>
     <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;ping()&#39;</span><span class="p">)</span>
 
-    <span class="nb">sum</span> <span class="o">=</span> <span 
class="n">client</span><span class="o">.</span><span class="n">add</span><span 
class="p">(</span><span class="mi">1</span><span class="p">,</span> <span 
class="mi">1</span><span class="p">)</span>
+    <span class="n">sum_</span> <span class="o">=</span> <span 
class="n">client</span><span class="o">.</span><span class="n">add</span><span 
class="p">(</span><span class="mi">1</span><span class="p">,</span> <span 
class="mi">1</span><span class="p">)</span>
 </pre></div>
 <p class='snippet_footer'>
   This snippet was generated by Apache Thrift's <strong>source tree 
docs</strong>:

Modified: websites/staging/thrift/trunk/content/lib/haxe.html
==============================================================================
--- websites/staging/thrift/trunk/content/lib/haxe.html (original)
+++ websites/staging/thrift/trunk/content/lib/haxe.html Wed Sep 21 21:34:51 2016
@@ -151,7 +151,8 @@ project files in these folders.</p>
 <h1 id="current-status">Current status<a class="headerlink" 
href="#current-status" title="Permanent link">&para;</a></h1>
 <ul>
 <li>tested with Haxe C++ target</li>
-<li>transports: Socket, HTTP (client only), Stream</li>
+<li>tested with Haxe PHP target (console/web server, binary protocols)</li>
+<li>transports: Socket, HTTP (servers run inside PHP server/PHP target only), 
Stream</li>
 <li>protocols: Binary, JSON, Multiplex, Compact</li>
 <li>tutorial client and server available</li>
 <li>cross-test client and server available </li>
@@ -166,11 +167,56 @@ project files in these folders.</p>
 <p>Although designed with maximum portability in mind, for technical reasons 
some platforms
 may only support parts of the library, or not be compatible at all.</p>
 <p>Javascript:
-- tutorial fails to build because of unsupported Sys.args
+- tutorial fails to build because of unsupported Sys.args</p>
+<h1 id="php-http-server-notes">PHP HTTP Server notes<a class="headerlink" 
href="#php-http-server-notes" title="Permanent link">&para;</a></h1>
+<ul>
+<li>
+<p>you have to import PHP files generated by haxe into PHP
+<code>php
+require_once  dirname(__FILE__) . 
'/bin/php-web-server/Main-debug.php';</code></p>
+</li>
+<li>
+<p>trace() by default outputs into stdout (http response), so you have to 
redirect it to stderr or you own logs, something like
+<code>haxe
+//remap trace to error log
+haxe.Log.trace = function(v:Dynamic, ?infos:haxe.PosInfos) 
+{ 
+    //simulate normal trace 
https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/Log.hx
+    var newValue : Dynamic;
+    if (infos != null &amp;&amp; infos.customParams!=null) {
+        var extra:String = "";
+        for( v in infos.customParams )
+            extra += "," + v;
+        newValue = v + extra;
+    }
+    else {
+        newValue = v;
+    }
+    var msg = infos != null ? infos.fileName + ':' + infos.lineNumber + ': ' : 
'';
+    Sys.stderr().writeString('${msg}${newValue}\n');
+}</code></p>
+</li>
+<li>
+<p>to allow thrift server to read/write HTTP request/response, it should be 
pointed out to php streams
+<code>haxe
+transport = new TWrappingServerTransport(
+                new TStreamTransport(
+                    new TFileStream("php://input", Read),
+                    new TFileStream("php://output", Append)
+                    )
+                );</code></p>
+</li>
+<li>
+<p>TSimpleServer doesn't stop after first call, so processor.process() should 
be called instead, or use runOnce property 
+<code>haxe
+var server = new TSimpleServer( processor, transport, transfactory, 
protfactory);
+server.runOnce = true;</code>
 <p class='snippet_footer'>
   This page was generated by Apache Thrift's <strong>source tree docs</strong>:
   <a 
href="http://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=lib/haxe/README.md;hb=HEAD";</a>lib/haxe/README.md</a>
 </p></p>
+</li>
+</ul>
        </div>
        <div class="container">
        <hr>

Modified: websites/staging/thrift/trunk/content/test/ThriftTest.html
==============================================================================
--- websites/staging/thrift/trunk/content/test/ThriftTest.html (original)
+++ websites/staging/thrift/trunk/content/test/ThriftTest.html Wed Sep 21 
21:34:51 2016
@@ -580,7 +580,7 @@ struct Bools {
 struct Xtruct
 {
   1:  string string_thing,
-  4:  byte   byte_thing,
+  4:  i8     byte_thing,
   9:  i32    i32_thing,
   11: i64    i64_thing
 }
@@ -658,7 +658,7 @@ service ThriftTest
    * @param byte thing - the i8/byte to print
    * @return i8 - returns the i8/byte &#39;thing&#39;
    */
-  i8         testByte(1: byte thing),
+  i8           testByte(1: i8 thing),
 
   /**
    * Prints &#39;testI32(&quot;%d&quot;)&#39; with thing as &#39;%d&#39;
@@ -771,7 +771,7 @@ service ThriftTest
 
   /**
    * Prints &#39;testMulti()&#39;
-   * @param byte arg0 -
+   * @param i8 arg0 -
    * @param i32 arg1 -
    * @param i64 arg2 -
    * @param map&lt;i16, string&gt; arg3 -
@@ -780,7 +780,7 @@ service ThriftTest
    * @return Xtruct - returns an Xtruct with string_thing = &quot;Hello2, 
byte_thing = arg0, i32_thing = arg1
    *    and i64_thing = arg2
    */
-  Xtruct testMulti(1: byte arg0, 2: i32 arg1, 3: i64 arg2, 4: map&lt;i16, 
string&gt; arg3, 5: Numberz arg4, 6: UserId arg5),
+  Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map&lt;i16, 
string&gt; arg3, 5: Numberz arg4, 6: UserId arg5),
 
   /**
    * Print &#39;testException(%s)&#39; with arg as &#39;%s&#39;
@@ -831,7 +831,7 @@ struct VersioningTestV2 {
        1: i32 begin_in_both,
 
        2: i32 newint,
-       3: byte newbyte,
+       3: i8 newbyte,
        4: i16 newshort,
        5: i64 newlong,
        6: double newdouble

Modified: websites/staging/thrift/trunk/content/test/keys.html
==============================================================================
--- websites/staging/thrift/trunk/content/test/keys.html (original)
+++ websites/staging/thrift/trunk/content/test/keys.html Wed Sep 21 21:34:51 
2016
@@ -148,6 +148,7 @@ Primary use are unit test suites and cro
 <span class="p">[</span> <span class="n">alternate_names</span> <span 
class="p">]</span>
 <span class="n">IP</span><span class="p">.</span>1<span 
class="p">=</span>127<span class="p">.</span>0<span class="p">.</span>0<span 
class="p">.</span>1
 <span class="n">IP</span><span class="p">.</span>2<span class="p">=::</span>1
+<span class="n">IP</span><span class="p">.</span>3<span 
class="p">=::</span><span class="n">ffff</span><span class="p">:</span>127<span 
class="p">.</span>0<span class="p">.</span>0<span class="p">.</span>1
 </pre></div>
 
 

Modified: websites/staging/thrift/trunk/content/tutorial/haxe.html
==============================================================================
--- websites/staging/thrift/trunk/content/tutorial/haxe.html (original)
+++ websites/staging/thrift/trunk/content/tutorial/haxe.html Wed Sep 21 
21:34:51 2016
@@ -125,293 +125,302 @@ import shared.</em>;</p>
     http;
 }</p>
 <p>class Main {</p>
-<div class="codehilite"><pre><span class="n">private</span> <span 
class="n">static</span> <span class="n">var</span> <span 
class="n">server</span> <span class="p">:</span> <span class="n">Bool</span> 
<span class="p">=</span> <span class="n">false</span><span class="p">;</span>
-<span class="n">private</span> <span class="n">static</span> <span 
class="n">var</span> <span class="n">framed</span> <span class="p">:</span> 
<span class="n">Bool</span> <span class="p">=</span> <span 
class="n">false</span><span class="p">;</span>
-<span class="n">private</span> <span class="n">static</span> <span 
class="n">var</span> <span class="n">buffered</span> <span class="p">:</span> 
<span class="n">Bool</span> <span class="p">=</span> <span 
class="n">false</span><span class="p">;</span>
-<span class="n">private</span> <span class="n">static</span> <span 
class="n">var</span> <span class="n">prot</span> <span class="p">:</span> <span 
class="n">Prot</span> <span class="p">=</span> <span 
class="n">binary</span><span class="p">;</span>
-<span class="n">private</span> <span class="n">static</span> <span 
class="n">var</span> <span class="n">trns</span> <span class="p">:</span> <span 
class="n">Trns</span> <span class="p">=</span> <span 
class="n">socket</span><span class="p">;</span>
-
-<span class="n">private</span> <span class="n">static</span> <span 
class="n">var</span> <span class="n">targetHost</span> <span class="p">:</span> 
<span class="n">String</span> <span class="p">=</span> &quot;<span 
class="n">localhost</span>&quot;<span class="p">;</span>
-<span class="n">private</span> <span class="n">static</span> <span 
class="n">var</span> <span class="n">targetPort</span> <span class="p">:</span> 
<span class="n">Int</span> <span class="p">=</span> 9090<span class="p">;</span>
-
-<span class="n">static</span> <span class="k">function</span> <span 
class="n">main</span><span class="p">()</span> <span class="p">{</span>
-    #<span class="k">if</span> ! <span class="p">(</span><span 
class="n">flash</span> <span class="o">||</span> <span class="n">js</span><span 
class="p">)</span>
-    <span class="k">try</span> <span class="p">{</span>
-          <span class="n">ParseArgs</span><span class="p">();</span>
-    <span class="p">}</span> <span class="k">catch</span> <span 
class="p">(</span><span class="n">e</span> <span class="p">:</span> <span 
class="n">String</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="n">e</span><span class="p">);</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="n">GetHelp</span><span class="p">());</span>
-        <span class="k">return</span><span class="p">;</span>
-    <span class="p">}</span>
-    #<span class="k">end</span>
-
-    <span class="k">try</span> <span class="p">{</span>
-        <span class="k">if</span> <span class="p">(</span><span 
class="n">server</span><span class="p">)</span>
-            <span class="n">RunServer</span><span class="p">();</span>
-        <span class="k">else</span>
-            <span class="n">RunClient</span><span class="p">();</span>
-    <span class="p">}</span> <span class="k">catch</span> <span 
class="p">(</span><span class="n">e</span> <span class="p">:</span> <span 
class="n">String</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="n">e</span><span class="p">);</span>
-    <span class="p">}</span>
-
-    <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="n">Completed</span><span class="p">.</span>&quot;<span 
class="p">);</span>
-<span class="p">}</span>
-
-
-#<span class="k">if</span> ! <span class="p">(</span><span 
class="n">flash</span> <span class="o">||</span> <span class="n">js</span><span 
class="p">)</span>
-
-<span class="n">private</span> <span class="n">static</span> <span 
class="k">function</span> <span class="n">GetHelp</span><span 
class="p">()</span> <span class="p">:</span> <span class="n">String</span> 
<span class="p">{</span>
-    <span class="k">return</span> <span class="n">Sys</span><span 
class="p">.</span><span class="n">executablePath</span><span 
class="p">()</span><span class="o">+</span>&quot;  <span class="n">modus</span> 
 <span class="n">trnsOption</span>  <span class="n">transport</span>  <span 
class="n">protocol</span><span class="o">\</span><span class="n">n</span>&quot;
-    <span class="o">+</span>&quot;<span class="n">Options</span><span 
class="p">:</span><span class="o">\</span><span class="n">n</span>&quot;
-    <span class="o">+</span>&quot;  <span class="n">modus</span><span 
class="p">:</span>       <span class="n">client</span><span class="p">,</span> 
<span class="n">server</span>   <span class="p">(</span><span 
class="n">default</span><span class="p">:</span> <span 
class="n">client</span><span class="p">)</span><span class="o">\</span><span 
class="n">n</span>&quot;
-    <span class="o">+</span>&quot;  <span class="n">trnsOption</span><span 
class="p">:</span>  <span class="n">framed</span><span class="p">,</span> <span 
class="n">buffered</span> <span class="p">(</span><span 
class="n">default</span><span class="p">:</span> <span 
class="n">none</span><span class="p">)</span><span class="o">\</span><span 
class="n">n</span>&quot;
-    <span class="o">+</span>&quot;  <span class="n">transport</span><span 
class="p">:</span>   <span class="n">socket</span><span class="p">,</span> 
<span class="n">http</span>     <span class="p">(</span><span 
class="n">default</span><span class="p">:</span> <span 
class="n">socket</span><span class="p">)</span><span class="o">\</span><span 
class="n">n</span>&quot;
-    <span class="o">+</span>&quot;  <span class="n">protocol</span><span 
class="p">:</span>    <span class="n">binary</span><span class="p">,</span> 
<span class="n">json</span>     <span class="p">(</span><span 
class="n">default</span><span class="p">:</span> <span 
class="n">binary</span><span class="p">)</span><span class="o">\</span><span 
class="n">n</span>&quot;
-    <span class="o">+</span>&quot;<span class="o">\</span><span 
class="n">n</span>&quot;
-    <span class="o">+</span>&quot;<span class="n">All</span> <span 
class="n">arguments</span> <span class="n">are</span> <span 
class="n">optional</span><span class="o">.\</span><span 
class="n">n</span>&quot;<span class="p">;</span>
-<span class="p">}</span>
-
-
-<span class="n">private</span> <span class="n">static</span> <span 
class="k">function</span> <span class="n">ParseArgs</span><span 
class="p">()</span> <span class="p">:</span> <span class="n">Void</span> <span 
class="p">{</span>
-    <span class="n">var</span> <span class="n">step</span> <span 
class="p">=</span> 0<span class="p">;</span>
-    <span class="k">for</span> <span class="p">(</span><span 
class="n">arg</span> <span class="n">in</span> <span class="n">Sys</span><span 
class="p">.</span><span class="n">args</span><span class="p">())</span> <span 
class="p">{</span>
-
-        <span class="o">//</span> <span class="n">server</span><span 
class="o">|</span><span class="n">client</span>
-        <span class="k">switch</span><span class="p">(</span><span 
class="n">step</span><span class="p">)</span> <span class="p">{</span>
-        <span class="k">case</span> 0<span class="p">:</span>
-            <span class="o">++</span><span class="n">step</span><span 
class="p">;</span>
-            <span class="k">if</span> <span class="p">(</span> <span 
class="n">arg</span> <span class="o">==</span> &quot;<span 
class="n">client</span>&quot;<span class="p">)</span>
-                <span class="n">server</span> <span class="p">=</span> <span 
class="n">false</span><span class="p">;</span>
-            <span class="k">else</span> <span class="k">if</span> <span 
class="p">(</span> <span class="n">arg</span> <span class="o">==</span> 
&quot;<span class="n">server</span>&quot;<span class="p">)</span>
-                <span class="n">server</span> <span class="p">=</span> <span 
class="n">true</span><span class="p">;</span>
-            <span class="k">else</span>
-                <span class="n">throw</span> &quot;<span 
class="n">First</span> <span class="n">argument</span> <span 
class="n">must</span> <span class="n">be</span> <span 
class="s">&#39;server&#39;</span> <span class="n">or</span> <span 
class="s">&#39;client&#39;</span>&quot;<span class="p">;</span>
-
-        <span class="k">case</span> 1<span class="p">:</span>
-            <span class="k">if</span> <span class="p">(</span> <span 
class="n">arg</span> <span class="o">==</span> &quot;<span 
class="n">framed</span>&quot;<span class="p">)</span> <span class="p">{</span>
-                <span class="n">framed</span> <span class="p">=</span> <span 
class="n">true</span><span class="p">;</span>
-            <span class="p">}</span> <span class="k">else</span> <span 
class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span 
class="o">==</span> &quot;<span class="n">buffered</span>&quot;<span 
class="p">)</span> <span class="p">{</span>
-                <span class="n">buffered</span> <span class="p">=</span> <span 
class="n">true</span><span class="p">;</span>
-            <span class="p">}</span> <span class="k">else</span> <span 
class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span 
class="o">==</span> &quot;<span class="n">socket</span>&quot;<span 
class="p">)</span> <span class="p">{</span>
-                <span class="n">trns</span> <span class="p">=</span> <span 
class="n">socket</span><span class="p">;</span>
-                <span class="o">++</span><span class="n">step</span><span 
class="p">;</span>
-            <span class="p">}</span> <span class="k">else</span> <span 
class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span 
class="o">==</span> &quot;<span class="n">http</span>&quot;<span 
class="p">)</span> <span class="p">{</span>
-                <span class="n">trns</span> <span class="p">=</span> <span 
class="n">http</span><span class="p">;</span>
-                <span class="o">++</span><span class="n">step</span><span 
class="p">;</span>
-            <span class="p">}</span> <span class="k">else</span> <span 
class="p">{</span>
-                <span class="n">throw</span> &quot;<span 
class="n">Unknown</span> <span class="n">transport</span> &quot;<span 
class="o">+</span><span class="n">arg</span><span class="p">;</span>
-            <span class="p">}</span>
-
-        <span class="k">case</span> 2<span class="p">:</span>
-            <span class="k">if</span> <span class="p">(</span> <span 
class="n">arg</span> <span class="o">==</span> &quot;<span 
class="n">binary</span>&quot;<span class="p">)</span> <span class="p">{</span>
-                <span class="n">prot</span> <span class="p">=</span> <span 
class="n">binary</span><span class="p">;</span>
-                <span class="o">++</span><span class="n">step</span><span 
class="p">;</span>
-            <span class="p">}</span> <span class="k">else</span> <span 
class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span 
class="o">==</span> &quot;<span class="n">json</span>&quot;<span 
class="p">)</span> <span class="p">{</span>
-                <span class="n">prot</span> <span class="p">=</span> <span 
class="n">json</span><span class="p">;</span>
-                <span class="o">++</span><span class="n">step</span><span 
class="p">;</span>
-            <span class="p">}</span> <span class="k">else</span> <span 
class="p">{</span>
-                <span class="n">throw</span> &quot;<span 
class="n">Unknown</span> <span class="n">protocol</span> &quot;<span 
class="o">+</span><span class="n">arg</span><span class="p">;</span>
-            <span class="p">}</span>
-
-        <span class="n">default</span><span class="p">:</span>
-            <span class="n">throw</span> &quot;<span 
class="n">Unexpected</span> <span class="n">argument</span> &quot;<span 
class="o">+</span><span class="n">arg</span><span class="p">;</span>
-        <span class="p">}</span>
-
-        <span class="k">if</span> <span class="p">(</span> <span 
class="n">framed</span> <span class="o">&amp;&amp;</span> <span 
class="n">buffered</span><span class="p">)</span>
-        <span class="p">{</span>
-            <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="n">WN</span><span class="p">:</span> <span class="n">framed</span> <span 
class="n">supersedes</span> <span class="n">buffered</span>&quot;<span 
class="p">);</span>
-        <span class="p">}</span>
-
-    <span class="p">}</span>
-<span class="p">}</span>
-
-#<span class="k">end</span>
-
-<span class="n">private</span> <span class="n">static</span> <span 
class="k">function</span> <span class="n">ClientSetup</span><span 
class="p">()</span> <span class="p">:</span> <span class="n">Calculator</span> 
<span class="p">{</span>
-     <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="n">Client</span> <span class="n">configuration</span><span 
class="p">:</span>&quot;<span class="p">);</span>
-
-    <span class="o">//</span> <span class="n">endpoint</span> <span 
class="n">transport</span>
-    <span class="n">var</span> <span class="n">transport</span> <span 
class="p">:</span> <span class="n">TTransport</span><span class="p">;</span>
-    <span class="k">switch</span><span class="p">(</span><span 
class="n">trns</span><span class="p">)</span>
-    <span class="p">{</span>
-    <span class="k">case</span> <span class="n">socket</span><span 
class="p">:</span>
-         <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;- socket transport $targetHost:$targetPort&#39;</span><span 
class="p">);</span>
-        <span class="n">transport</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TSocket</span><span class="p">(</span> 
<span class="n">targetHost</span><span class="p">,</span> <span 
class="n">targetPort</span><span class="p">);</span>
-    <span class="k">case</span> <span class="n">http</span><span 
class="p">:</span>
-         <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;- HTTP transport $targetHost&#39;</span><span class="p">);</span>
-        <span class="n">transport</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">THttpClient</span><span class="p">(</span> 
<span class="n">targetHost</span><span class="p">);</span>
-    <span class="n">default</span><span class="p">:</span>
-        <span class="n">throw</span> &quot;<span class="n">Unhandled</span> 
<span class="n">transport</span>&quot;<span class="p">;</span>
-    <span class="p">}</span>
-
-
-    <span class="o">//</span> <span class="n">optinal</span> <span 
class="n">layered</span> <span class="n">transport</span>
-    <span class="k">if</span> <span class="p">(</span> <span 
class="n">framed</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">framed</span> <span 
class="n">transport</span>&quot;<span class="p">);</span>
-        <span class="n">transport</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TFramedTransport</span><span 
class="p">(</span><span class="n">transport</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">else</span> <span 
class="k">if</span> <span class="p">(</span> <span 
class="n">buffered</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">buffered</span> <span 
class="n">transport</span>&quot;<span class="p">);</span>
-        <span class="n">transport</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TBufferedTransport</span><span 
class="p">(</span><span class="n">transport</span><span class="p">);</span>
-    <span class="p">}</span>
-
-
-    <span class="o">//</span> <span class="n">protocol</span>
-    <span class="n">var</span> <span class="n">protocol</span> <span 
class="p">:</span> <span class="n">TProtocol</span><span class="p">;</span>
-    <span class="k">switch</span><span class="p">(</span><span 
class="n">prot</span><span class="p">)</span>
-    <span class="p">{</span>
-    <span class="k">case</span> <span class="n">binary</span><span 
class="p">:</span>
-         <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">binary</span> <span 
class="n">protocol</span>&quot;<span class="p">);</span>
-         <span class="n">protocol</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TBinaryProtocol</span><span 
class="p">(</span> <span class="n">transport</span><span class="p">);</span>
-    <span class="k">case</span> <span class="n">json</span><span 
class="p">:</span>
-         <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">JSON</span> <span 
class="n">protocol</span>&quot;<span class="p">);</span>
-         <span class="n">protocol</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TJSONProtocol</span><span 
class="p">(</span> <span class="n">transport</span><span class="p">);</span>
-    <span class="n">default</span><span class="p">:</span>
-        <span class="n">throw</span> &quot;<span class="n">Unhandled</span> 
<span class="n">protocol</span>&quot;<span class="p">;</span>
-    <span class="p">}</span>
-
-
-    <span class="o">//</span> <span class="n">put</span> <span 
class="n">everything</span> <span class="n">together</span>
-    <span class="n">transport</span><span class="p">.</span><span 
class="n">open</span><span class="p">();</span>
-    <span class="k">return</span> <span class="n">new</span> <span 
class="n">CalculatorImpl</span><span class="p">(</span><span 
class="n">protocol</span><span class="p">,</span><span 
class="n">protocol</span><span class="p">);</span>
-<span class="p">}</span>
-
-
-<span class="n">private</span> <span class="n">static</span> <span 
class="k">function</span> <span class="n">RunClient</span><span 
class="p">()</span> <span class="p">:</span> <span class="n">Void</span> <span 
class="p">{</span>
-    <span class="n">var</span> <span class="n">client</span> <span 
class="p">=</span> <span class="n">ClientSetup</span><span class="p">();</span>
-
-    <span class="k">try</span> <span class="p">{</span>
-          <span class="n">client</span><span class="p">.</span><span 
class="n">ping</span><span class="p">();</span>
-        <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="n">ping</span><span class="p">()</span> <span 
class="n">successful</span>&quot;<span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">TException</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;ping() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;ping() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span>
-
-    <span class="k">try</span> <span class="p">{</span>
-        <span class="n">var</span> <span class="n">sum</span> <span 
class="p">=</span> <span class="n">client</span><span class="p">.</span><span 
class="n">add</span><span class="p">(</span> 1<span class="p">,</span> 1<span 
class="p">);</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;1+1=$sum&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">TException</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;add() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;add() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span>
-
-
-    <span class="n">var</span> <span class="n">work</span> <span 
class="p">=</span> <span class="n">new</span> <span 
class="n">tutorial</span><span class="p">.</span><span 
class="n">Work</span><span class="p">();</span>
-    <span class="n">work</span><span class="p">.</span><span 
class="n">op</span> <span class="p">=</span> <span 
class="n">tutorial</span><span class="p">.</span><span 
class="n">Operation</span><span class="p">.</span><span 
class="n">DIVIDE</span><span class="p">;</span>
-    <span class="n">work</span><span class="p">.</span><span 
class="n">num1</span> <span class="p">=</span> 1<span class="p">;</span>
-    <span class="n">work</span><span class="p">.</span><span 
class="n">num2</span> <span class="p">=</span> 0<span class="p">;</span>
-    <span class="k">try</span> <span class="p">{</span>
-        <span class="n">var</span> <span class="n">quotient</span> <span 
class="p">=</span> <span class="n">client</span><span class="p">.</span><span 
class="n">calculate</span><span class="p">(</span> 1<span class="p">,</span> 
<span class="n">work</span><span class="p">);</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;Whoa we can divide by 0! Result = $quotient&#39;</span><span 
class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">TException</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;calculate() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;calculate() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span>
-
-    <span class="n">work</span><span class="p">.</span><span 
class="n">op</span> <span class="p">=</span> <span 
class="n">tutorial</span><span class="p">.</span><span 
class="n">Operation</span><span class="p">.</span><span 
class="n">SUBTRACT</span><span class="p">;</span>
-    <span class="n">work</span><span class="p">.</span><span 
class="n">num1</span> <span class="p">=</span> 15<span class="p">;</span>
-    <span class="n">work</span><span class="p">.</span><span 
class="n">num2</span> <span class="p">=</span> 10<span class="p">;</span>
-    <span class="k">try</span> <span class="p">{</span>
-        <span class="n">var</span> <span class="n">diff</span> <span 
class="p">=</span> <span class="n">client</span><span class="p">.</span><span 
class="n">calculate</span><span class="p">(</span> 1<span class="p">,</span> 
<span class="n">work</span><span class="p">);</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;15-10=$diff&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">TException</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;calculate() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;calculate() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span>
-
-
-    <span class="k">try</span> <span class="p">{</span>
-        <span class="n">var</span> <span class="nb">log</span> <span 
class="p">:</span> <span class="n">SharedStruct</span> <span class="p">=</span> 
<span class="n">client</span><span class="p">.</span><span 
class="n">getStruct</span><span class="p">(</span> 1<span class="p">);</span>
-        <span class="n">var</span> <span class="n">logval</span> <span 
class="p">=</span> <span class="nb">log</span><span class="p">.</span><span 
class="n">value</span><span class="p">;</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;Check log: $logval&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">TException</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;getStruct() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">catch</span><span 
class="p">(</span><span class="n">error</span> <span class="p">:</span> <span 
class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;getStruct() failed: $error&#39;</span><span class="p">);</span>
-    <span class="p">}</span>
-<span class="p">}</span>
-
-
-<span class="n">private</span> <span class="n">static</span> <span 
class="k">function</span> <span class="n">ServerSetup</span><span 
class="p">()</span> <span class="p">:</span> <span class="n">TServer</span> 
<span class="p">{</span>
-     <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="n">Server</span> <span class="n">configuration</span><span 
class="p">:</span>&quot;<span class="p">);</span>
-
-    <span class="o">//</span> <span class="n">endpoint</span> <span 
class="n">transport</span>
-    <span class="n">var</span> <span class="n">transport</span> <span 
class="p">:</span> <span class="n">TServerTransport</span> <span 
class="p">=</span> <span class="n">null</span><span class="p">;</span>
-    <span class="k">switch</span><span class="p">(</span><span 
class="n">trns</span><span class="p">)</span>
-    <span class="p">{</span>
-    <span class="k">case</span> <span class="n">socket</span><span 
class="p">:</span>
-        #<span class="k">if</span> <span class="p">(</span><span 
class="n">flash</span> <span class="o">||</span> <span class="n">js</span><span 
class="p">)</span>
-        <span class="n">throw</span> <span class="s">&#39;current platform 
does not support socket servers&#39;</span><span class="p">;</span>
-        #<span class="k">else</span>
-         <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;- socket transport port $targetPort&#39;</span><span 
class="p">);</span>
-        <span class="n">transport</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TServerSocket</span><span 
class="p">(</span> <span class="n">targetPort</span><span class="p">);</span>
-        #<span class="k">end</span>
-    <span class="k">case</span> <span class="n">http</span><span 
class="p">:</span>
-        <span class="n">throw</span> &quot;<span class="n">HTTP</span> <span 
class="n">server</span> <span class="n">not</span> <span 
class="n">implemented</span> <span class="n">yet</span>&quot;<span 
class="p">;</span>
-         <span class="o">//</span><span class="n">trace</span><span 
class="p">(</span>&quot;<span class="o">-</span> <span class="n">http</span> 
<span class="n">transport</span>&quot;<span class="p">);</span>
-         <span class="o">//</span><span class="n">transport</span> <span 
class="p">=</span> <span class="n">new</span> <span 
class="n">THttpClient</span><span class="p">(</span> <span 
class="n">targetHost</span><span class="p">);</span>
-    <span class="n">default</span><span class="p">:</span>
-        <span class="n">throw</span> &quot;<span class="n">Unhandled</span> 
<span class="n">transport</span>&quot;<span class="p">;</span>
-    <span class="p">}</span>
-
-    <span class="o">//</span> <span class="n">optional</span><span 
class="p">:</span> <span class="n">layered</span> <span 
class="n">transport</span>
-    <span class="n">var</span> <span class="n">transfactory</span> <span 
class="p">:</span> <span class="n">TTransportFactory</span> <span 
class="p">=</span> <span class="n">null</span><span class="p">;</span>
-    <span class="k">if</span> <span class="p">(</span> <span 
class="n">framed</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">framed</span> <span 
class="n">transport</span>&quot;<span class="p">);</span>
-        <span class="n">transfactory</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TFramedTransportFactory</span><span 
class="p">();</span>
-    <span class="p">}</span> <span class="k">else</span> <span 
class="k">if</span> <span class="p">(</span> <span 
class="n">buffered</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">buffered</span> <span 
class="n">transport</span>&quot;<span class="p">);</span>
-        <span class="n">transfactory</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TBufferedTransportFactory</span><span 
class="p">();</span>
-    <span class="p">}</span>
-
-    <span class="o">//</span> <span class="n">protocol</span>
-    <span class="n">var</span> <span class="n">protfactory</span> <span 
class="p">:</span> <span class="n">TProtocolFactory</span> <span 
class="p">=</span> <span class="n">null</span><span class="p">;</span>
-    <span class="k">switch</span><span class="p">(</span><span 
class="n">prot</span><span class="p">)</span>
-    <span class="p">{</span>
-    <span class="k">case</span> <span class="n">binary</span><span 
class="p">:</span>
-         <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">binary</span> <span 
class="n">protocol</span>&quot;<span class="p">);</span>
-         <span class="n">protfactory</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TBinaryProtocolFactory</span><span 
class="p">();</span>
-    <span class="k">case</span> <span class="n">json</span><span 
class="p">:</span>
-        <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">-</span> <span class="n">JSON</span> <span 
class="n">protocol</span>&quot;<span class="p">);</span>
-         <span class="n">protfactory</span> <span class="p">=</span> <span 
class="n">new</span> <span class="n">TJSONProtocolFactory</span><span 
class="p">();</span>
-    <span class="n">default</span><span class="p">:</span>
-        <span class="n">throw</span> &quot;<span class="n">Unhandled</span> 
<span class="n">protocol</span>&quot;<span class="p">;</span>
-    <span class="p">}</span>
-
-    <span class="n">var</span> <span class="n">handler</span> <span 
class="p">=</span> <span class="n">new</span> <span 
class="n">CalculatorHandler</span><span class="p">();</span>
-    <span class="n">var</span> <span class="n">processor</span> <span 
class="p">=</span> <span class="n">new</span> <span 
class="n">CalculatorProcessor</span><span class="p">(</span><span 
class="n">handler</span><span class="p">);</span>
-    <span class="n">var</span> <span class="n">server</span> <span 
class="p">=</span> <span class="n">new</span> <span 
class="n">TSimpleServer</span><span class="p">(</span> <span 
class="n">processor</span><span class="p">,</span> <span 
class="n">transport</span><span class="p">,</span> <span 
class="n">transfactory</span><span class="p">,</span> <span 
class="n">protfactory</span><span class="p">);</span>
-    <span class="k">return</span> <span class="n">server</span><span 
class="p">;</span>
-<span class="p">}</span>
-
-
-<span class="n">private</span> <span class="n">static</span> <span 
class="k">function</span> <span class="n">RunServer</span><span 
class="p">()</span> <span class="p">:</span> <span class="n">Void</span> <span 
class="p">{</span>
-    <span class="k">try</span>
-    <span class="p">{</span>
-        <span class="n">var</span> <span class="n">server</span> <span 
class="p">=</span> <span class="n">ServerSetup</span><span class="p">();</span>
-
-        <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="o">\</span><span class="n">nStarting</span> <span class="n">the</span> 
<span class="n">server</span><span class="p">...</span>&quot;<span 
class="p">);</span>
-        <span class="n">server</span><span class="p">.</span><span 
class="n">Serve</span><span class="p">();</span>
-    <span class="p">}</span>
-    <span class="k">catch</span><span class="p">(</span> <span 
class="n">e</span> <span class="p">:</span> <span class="n">Dynamic</span><span 
class="p">)</span>
-    <span class="p">{</span>
-        <span class="n">trace</span><span class="p">(</span><span 
class="s">&#39;RunServer() failed: $e&#39;</span><span class="p">);</span>
-    <span class="p">}</span>
-    <span class="n">trace</span><span class="p">(</span>&quot;<span 
class="n">done</span><span class="p">.</span>&quot;<span class="p">);</span>
-<span class="p">}</span>
+<div class="codehilite"><pre>private static var server : Bool = false;
+private static var framed : Bool = false;
+private static var buffered : Bool = false;
+private static var prot : Prot = binary;
+private static var trns : Trns = socket;
+
+private static var targetHost : String = &quot;localhost&quot;;
+private static var targetPort : Int = 9090;
+
+static function main() {
+
+    #if ! (flash || js || phpwebserver)
+    try {
+          ParseArgs();
+    } catch (e : String) {
+        trace(e);
+        trace(GetHelp());
+        return;
+    }
+
+    #elseif  phpwebserver
+    //forcing server
+    server = true;
+    trns = http;
+    initPhpWebServer();
+    //check method
+    if(php.Web.getMethod() != &#39;POST&#39;) {
+      Sys.println(&#39;http endpoint for thrift test server&#39;);
+      return;
+    }
+    #end
+
+    try {
+        if (server)
+            RunServer();
+        else
+            RunClient();
+    } catch (e : String) {
+        trace(e);
+    }
+
+    trace(&quot;Completed.&quot;);
+}
+
+#if phpwebserver
+private static function initPhpWebServer()
+{
+    //remap trace to error log
+    haxe.Log.trace = function(v:Dynamic, ?infos:haxe.PosInfos)
+    {
+      // handle trace
+      var newValue : Dynamic;
+      if (infos != null <span class="err">&amp;&amp;</span> 
infos.customParams!=null) {
+        var extra:String = &quot;&quot;;
+        for( v in infos.customParams )
+          extra += &quot;,&quot; + v;
+        newValue = v + extra;
+      }
+      else {
+        newValue = v;
+      }
+      var msg = infos != null ? infos.fileName + &#39;:&#39; + 
infos.lineNumber + &#39;: &#39; : &#39;&#39;;
+      Sys.stderr().writeString(&#39;<span class="cp">${</span><span 
class="n">msg</span><span class="cp">}${</span><span 
class="n">newValue</span><span class="cp">}</span>\n&#39;);
+    }
+}
+#end
+
+
+#if ! (flash || js)
+
+private static function GetHelp() : String {
+    return Sys.executablePath()+&quot;  modus  trnsOption  transport  
protocol\n&quot;
+    +&quot;Options:\n&quot;
+    +&quot;  modus:       client, server   (default: client)\n&quot;
+    +&quot;  trnsOption:  framed, buffered (default: none)\n&quot;
+    +&quot;  transport:   socket, http     (default: socket)\n&quot;
+    +&quot;  protocol:    binary, json     (default: binary)\n&quot;
+    +&quot;\n&quot;
+    +&quot;All arguments are optional.\n&quot;;
+}
+
+
+private static function ParseArgs() : Void {
+    var step = 0;
+    for (arg in Sys.args()) {
+
+        // server|client
+        switch(step) {
+        case 0:
+            ++step;
+            if ( arg == &quot;client&quot;)
+                server = false;
+            else if ( arg == &quot;server&quot;)
+                server = true;
+            else
+                throw &quot;First argument must be &#39;server&#39; or 
&#39;client&#39;&quot;;
+
+        case 1:
+            if ( arg == &quot;framed&quot;) {
+                framed = true;
+            } else if ( arg == &quot;buffered&quot;) {
+                buffered = true;
+            } else if ( arg == &quot;socket&quot;) {
+                trns = socket;
+                ++step;
+            } else if ( arg == &quot;http&quot;) {
+                trns = http;
+                ++step;
+            } else {
+                throw &quot;Unknown transport &quot;+arg;
+            }
+
+        case 2:
+            if ( arg == &quot;binary&quot;) {
+                prot = binary;
+                ++step;
+            } else if ( arg == &quot;json&quot;) {
+                prot = json;
+                ++step;
+            } else {
+                throw &quot;Unknown protocol &quot;+arg;
+            }
+
+        default:
+            throw &quot;Unexpected argument &quot;+arg;
+        }
+
+        if ( framed <span class="err">&amp;&amp;</span> buffered)
+        {
+            trace(&quot;WN: framed supersedes buffered&quot;);
+        }
+
+    }
+}
+
+#end
+
+private static function ClientSetup() : Calculator {
+     trace(&quot;Client configuration:&quot;);
+
+    // endpoint transport
+    var transport : TTransport;
+    switch(trns)
+    {
+    case socket:
+         trace(&#39;- socket transport <span 
class="nv">$targetHost</span>:<span class="nv">$targetPort</span>&#39;);
+        transport = new TSocket( targetHost, targetPort);
+    case http:
+        var uri = &#39;http://<span class="cp">${</span><span 
class="n">targetHost</span><span class="cp">}</span>:<span 
class="cp">${</span><span class="n">targetPort</span><span 
class="cp">}</span>&#39;;
+        trace(&#39;- HTTP transport <span class="nv">$uri</span>&#39;);
+        transport = new THttpClient(uri);
+    default:
+        throw &quot;Unhandled transport&quot;;
+    }
+
+
+    // optinal layered transport
+    if ( framed) {
+        trace(&quot;- framed transport&quot;);
+        transport = new TFramedTransport(transport);
+    } else if ( buffered) {
+        trace(&quot;- buffered transport&quot;);
+        transport = new TBufferedTransport(transport);
+    }
+
+
+    // protocol
+    var protocol : TProtocol;
+    switch(prot)
+    {
+    case binary:
+         trace(&quot;- binary protocol&quot;);
+         protocol = new TBinaryProtocol( transport);
+    case json:
+         trace(&quot;- JSON protocol&quot;);
+         protocol = new TJSONProtocol( transport);
+    default:
+        throw &quot;Unhandled protocol&quot;;
+    }
+
+
+    // put everything together
+    transport.open();
+    return new CalculatorImpl(protocol,protocol);
+}
+
+
+private static function RunClient() : Void {
+    var client = ClientSetup();
+
+    try {
+          client.ping();
+        trace(&quot;ping() successful&quot;);
+    } catch(error : TException) {
+        trace(&#39;ping() failed: <span class="nv">$error</span>&#39;);
+    } catch(error : Dynamic) {
+        trace(&#39;ping() failed: <span class="nv">$error</span>&#39;);
+    }
+
+    try {
+        var sum = client.add( 1, 1);
+        trace(&#39;1+1=<span class="nv">$sum</span>&#39;);
+    } catch(error : TException) {
+        trace(&#39;add() failed: <span class="nv">$error</span>&#39;);
+    } catch(error : Dynamic) {
+        trace(&#39;add() failed: <span class="nv">$error</span>&#39;);
+    }
+
+
+    var work = new tutorial.Work();
+    work.op = tutorial.Operation.DIVIDE;
+    work.num1 = 1;
+    work.num2 = 0;
+    try {
+        var quotient = client.calculate( 1, work);
+        trace(&#39;Whoa we can divide by 0! Result = <span 
class="nv">$quotient</span>&#39;);
+    } catch(error : TException) {
+        trace(&#39;calculate() failed: <span class="nv">$error</span>&#39;);
+    } catch(error : Dynamic) {
+        trace(&#39;calculate() failed: <span class="nv">$error</span>&#39;);
+    }
+
+    work.op = tutorial.Operation.SUBTRACT;
+    work.num1 = 15;
+    work.num2 = 10;
+    try {
+        var diff = client.calculate( 1, work);
+        trace(&#39;15-10=<span class="nv">$diff</span>&#39;);
+    } catch(error : TException) {
+        trace(&#39;calculate() failed: <span class="nv">$error</span>&#39;);
+    } catch(error : Dynamic) {
+        trace(&#39;calculate() failed: <span class="nv">$error</span>&#39;);
+    }
+
+
+    try {
+        var log : SharedStruct = client.getStruct( 1);
+        var logval = log.value;
+        trace(&#39;Check log: <span class="nv">$logval</span>&#39;);
+    } catch(error : TException) {
+        trace(&#39;getStruct() failed: <span class="nv">$error</span>&#39;);
+    } catch(error : Dynamic) {
+        trace(&#39;getStruct() failed: <span class="nv">$error</span>&#39;);
+    }
+}
+
+
+private static function ServerSetup() : TServer {
+     trace(&quot;Server configuration:&quot;);
+
+    // endpoint transport
+    var transport : TServerTransport = null;
+    switch(trns)
+    {
+    case socket:
+        #if (flash || js)
+        throw &#39;current platform does not support socket servers&#39;;
+        #else
+         trace(&#39;- socket transport port <span 
class="nv">$targetPort</span>&#39;);
+        transport = new TServerSocket( targetPort);
+        #end
+    case http:
+        #if !phpwebserver
+          throw &quot;HTTP server not implemented yet&quot;;
+          //trace(&quot;- http transport&quot;);
+          //transport = new THttpClient( targetHost);
+        #else
+          trace(&quot;- http transport&quot;);
+          transport = new TWrappingServerTransport(
+                  new TStreamTransport(
+                    new TFileStream(&quot;php://input&quot;, Read),
+                    new TFileStream(&quot;php://output&quot;, Append)
+                    )
+                  );
+
+        #end
+    default:
+        throw &quot;Unhandled transport&quot;;
+    }
+
+    // optional: layered transport
+    var transfactory : TTransportFactory = null;
+    if ( framed) {
+        trace(&quot;- framed transport&quot;);
+        transfactory = new TFramedTransportFactory();
+    } else if ( buffered) {
+        trace(&quot;- buffered transport&quot;);
+        transfactory = new TBufferedTransportFactory();
+    }
 </pre></div>
 
 
-<p>}</p>
-<p class='snippet_footer'>
+<p><p class='snippet_footer'>
   This snippet was generated by Apache Thrift's <strong>source tree 
docs</strong>:
   <a 
href="http://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=tutorial/haxe/src/Main.hx;hb=HEAD";</a>tutorial/haxe/src/Main.hx</a>
-</p>
-
+</p></p>
 <p>Were done with the client, but need some more for the server: A service 
handler implementaion.</p>
 <h3 id="server">Server<a class="headerlink" href="#server" title="Permanent 
link">&para;</a></h3>
 <p>As the name suggests, the service handler implements the Thrift service on 
the server side. 

Modified: websites/staging/thrift/trunk/content/tutorial/nodejs.html
==============================================================================
--- websites/staging/thrift/trunk/content/tutorial/nodejs.html (original)
+++ websites/staging/thrift/trunk/content/tutorial/nodejs.html Wed Sep 21 
21:34:51 2016
@@ -116,13 +116,11 @@ h2:hover > .headerlink, h3:hover > .head
 h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, 
h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, 
dt:hover > .elementid-permalink { visibility: visible }</style>
 
 <div class="codehilite"><pre><span class="kd">var</span> <span 
class="nx">thrift</span> <span class="o">=</span> <span 
class="nx">require</span><span class="p">(</span><span 
class="s1">&#39;thrift&#39;</span><span class="p">);</span>
-<span class="kd">var</span> <span class="nx">ThriftTransports</span> <span 
class="o">=</span> <span class="nx">require</span><span class="p">(</span><span 
class="s1">&#39;thrift/transport&#39;</span><span class="p">);</span>
-<span class="kd">var</span> <span class="nx">ThriftProtocols</span> <span 
class="o">=</span> <span class="nx">require</span><span class="p">(</span><span 
class="s1">&#39;thrift/protocol&#39;</span><span class="p">);</span>
 <span class="kd">var</span> <span class="nx">Calculator</span> <span 
class="o">=</span> <span class="nx">require</span><span class="p">(</span><span 
class="s1">&#39;./gen-nodejs/Calculator&#39;</span><span class="p">);</span>
 <span class="kd">var</span> <span class="nx">ttypes</span> <span 
class="o">=</span> <span class="nx">require</span><span class="p">(</span><span 
class="s1">&#39;./gen-nodejs/tutorial_types&#39;</span><span class="p">);</span>
 
-<span class="nx">transport</span> <span class="o">=</span> <span 
class="nx">ThriftTransports</span><span class="p">.</span><span 
class="nx">TBufferedTransport</span><span class="p">()</span>
-<span class="nx">protocol</span> <span class="o">=</span> <span 
class="nx">ThriftProtocols</span><span class="p">.</span><span 
class="nx">TBinaryProtocol</span><span class="p">()</span>
+<span class="kd">var</span> <span class="nx">transport</span> <span 
class="o">=</span> <span class="nx">thrift</span><span class="p">.</span><span 
class="nx">TBufferedTransport</span><span class="p">;</span>
+<span class="kd">var</span> <span class="nx">protocol</span> <span 
class="o">=</span> <span class="nx">thrift</span><span class="p">.</span><span 
class="nx">TBinaryProtocol</span><span class="p">;</span>
 
 <span class="kd">var</span> <span class="nx">connection</span> <span 
class="o">=</span> <span class="nx">thrift</span><span class="p">.</span><span 
class="nx">createConnection</span><span class="p">(</span><span 
class="s2">&quot;localhost&quot;</span><span class="p">,</span> <span 
class="mi">9090</span><span class="p">,</span> <span class="p">{</span>
   <span class="nx">transport</span> <span class="o">:</span> <span 
class="nx">transport</span><span class="p">,</span>

Modified: websites/staging/thrift/trunk/content/tutorial/py.html
==============================================================================
--- websites/staging/thrift/trunk/content/tutorial/py.html (original)
+++ websites/staging/thrift/trunk/content/tutorial/py.html Wed Sep 21 21:34:51 
2016
@@ -148,8 +148,8 @@ h2:hover > .headerlink, h3:hover > .head
     <span class="n">client</span><span class="o">.</span><span 
class="n">ping</span><span class="p">()</span>
     <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;ping()&#39;</span><span class="p">)</span>
 
-    <span class="nb">sum</span> <span class="o">=</span> <span 
class="n">client</span><span class="o">.</span><span class="n">add</span><span 
class="p">(</span><span class="mi">1</span><span class="p">,</span> <span 
class="mi">1</span><span class="p">)</span>
-    <span class="k">print</span><span class="p">((</span><span 
class="s">&#39;1+1=</span><span class="si">%d</span><span 
class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span 
class="nb">sum</span><span class="p">)))</span>
+    <span class="n">sum_</span> <span class="o">=</span> <span 
class="n">client</span><span class="o">.</span><span class="n">add</span><span 
class="p">(</span><span class="mi">1</span><span class="p">,</span> <span 
class="mi">1</span><span class="p">)</span>
+    <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;1+1=</span><span class="si">%d</span><span 
class="s">&#39;</span> <span class="o">%</span> <span 
class="n">sum_</span><span class="p">)</span>
 
     <span class="n">work</span> <span class="o">=</span> <span 
class="n">Work</span><span class="p">()</span>
 
@@ -162,17 +162,17 @@ h2:hover > .headerlink, h3:hover > .head
         <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;Whoa? You know how to divide by zero?&#39;</span><span 
class="p">)</span>
         <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;FYI the answer is </span><span class="si">%d</span><span 
class="s">&#39;</span> <span class="o">%</span> <span 
class="n">quotient</span><span class="p">)</span>
     <span class="k">except</span> <span class="n">InvalidOperation</span> 
<span class="k">as</span> <span class="n">e</span><span class="p">:</span>
-        <span class="k">print</span><span class="p">((</span><span 
class="s">&#39;InvalidOperation: </span><span class="si">%r</span><span 
class="s">&#39;</span> <span class="o">%</span> <span class="n">e</span><span 
class="p">))</span>
+        <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;InvalidOperation: </span><span class="si">%r</span><span 
class="s">&#39;</span> <span class="o">%</span> <span class="n">e</span><span 
class="p">)</span>
 
     <span class="n">work</span><span class="o">.</span><span 
class="n">op</span> <span class="o">=</span> <span 
class="n">Operation</span><span class="o">.</span><span 
class="n">SUBTRACT</span>
     <span class="n">work</span><span class="o">.</span><span 
class="n">num1</span> <span class="o">=</span> <span class="mi">15</span>
     <span class="n">work</span><span class="o">.</span><span 
class="n">num2</span> <span class="o">=</span> <span class="mi">10</span>
 
     <span class="n">diff</span> <span class="o">=</span> <span 
class="n">client</span><span class="o">.</span><span 
class="n">calculate</span><span class="p">(</span><span 
class="mi">1</span><span class="p">,</span> <span class="n">work</span><span 
class="p">)</span>
-    <span class="k">print</span><span class="p">((</span><span 
class="s">&#39;15-10=</span><span class="si">%d</span><span 
class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span 
class="n">diff</span><span class="p">)))</span>
+    <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;15-10=</span><span class="si">%d</span><span 
class="s">&#39;</span> <span class="o">%</span> <span 
class="n">diff</span><span class="p">)</span>
 
     <span class="n">log</span> <span class="o">=</span> <span 
class="n">client</span><span class="o">.</span><span 
class="n">getStruct</span><span class="p">(</span><span 
class="mi">1</span><span class="p">)</span>
-    <span class="k">print</span><span class="p">((</span><span 
class="s">&#39;Check log: </span><span class="si">%s</span><span 
class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span 
class="n">log</span><span class="o">.</span><span class="n">value</span><span 
class="p">)))</span>
+    <span class="k">print</span><span class="p">(</span><span 
class="s">&#39;Check log: </span><span class="si">%s</span><span 
class="s">&#39;</span> <span class="o">%</span> <span class="n">log</span><span 
class="o">.</span><span class="n">value</span><span class="p">)</span>
 
     <span class="c"># Close!</span>
     <span class="n">transport</span><span class="o">.</span><span 
class="n">close</span><span class="p">()</span>
@@ -269,8 +269,9 @@ h2:hover > .headerlink, h3:hover > .head
     <span class="n">server</span> <span class="o">=</span> <span 
class="n">TServer</span><span class="o">.</span><span 
class="n">TSimpleServer</span><span class="p">(</span><span 
class="n">processor</span><span class="p">,</span> <span 
class="n">transport</span><span class="p">,</span> <span 
class="n">tfactory</span><span class="p">,</span> <span 
class="n">pfactory</span><span class="p">)</span>
 
     <span class="c"># You could do one of these for a multithreaded 
server</span>
-    <span class="c"># server = TServer.TThreadedServer(processor, transport, 
tfactory, pfactory)</span>
-    <span class="c"># server = TServer.TThreadPoolServer(processor, transport, 
tfactory, pfactory)</span>
+    <span class="c"># server = TServer.TThreadedServer(</span>
+    <span class="c">#     processor, transport, tfactory, pfactory)</span>
+    <span class="c"># server = TServer.TThreadPoolServer(</span>
 </pre></div>
 
 <p class='snippet_footer'>


Reply via email to