Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 127 lines (99 sloc) 4.458 kb
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
1
2 <erl>
3
4
5 box(Str) ->
6 {'div',[{class,"box"}],
7 {pre,[], yaws_api:htmlize(Str)}}.
8
9 tbox(T) ->
10 box(lists:flatten(io_lib:format("~p",[T]))).
11
12
13 ssi(File) ->
14 {'div',[{class,"box"}],
15 {pre,[],
16 {ssi, File,[],[]}}}.
17
18 ss(A, File) ->
19 {ok, B} = file:read_file(
0be3c7e @klacke untabified all of yaws
authored
20 filename:join([A#arg.docroot, File])),
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
21 box(binary_to_list(B)).
22
23
7811247 @vinoski whitespace cleanup
vinoski authored
24
25 out(A) ->
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
26 [{ssi, "TAB.inc", "%%",[{"haxe_intro", "choosen"}]},
27 {ehtml,
28 {'div', [{id, "entry"}],
29
30 [{h1, [], "haXe remoting"},
7811247 @vinoski whitespace cleanup
vinoski authored
31
0be3c7e @klacke untabified all of yaws
authored
32 {p, [],
33 ["The yaws_rpc module has a haXe remoting adapter that enables "
34 "Yaws to respond to respond to "
35 "RPC requests from a client written in ",
36 {a, [{href, "http://www.haxe.org"}], "haXe"},
37 ". haXe is a versatile open source language that compiles to "
38 "Flash, Javascript and NekoVM. ",
39 "For more information on haXe, visit ",
40 {a, [{href, "http://www.haxe.org/intro"}], "www.haxe.org/intro"}, "."]},
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
41 {p, [],
0be3c7e @klacke untabified all of yaws
authored
42 ["Implementing the server side of a haXe remoting interaction "
43 "in Yaws is very similar to the one described in the ",
44 {a, [{href, "json_intro.yaws"}], "Ajax/JSON RPC"}, " page. "
45 "Most of the action takes place behind the scenes inside the "
46 "the yaws_rpc module. The same types (array, struct, number "
47 "and string) work for haXe remoting as for JSON RPC. "
48 "There are just a few new things to keep in mind when using "
49 "haXe remoting: "
50 ]},
51 {ol, [],
52 [
53 {li, [], {p, [], "Class objects and enums work with standard "
54 "haXe remoting, but are not supported in Yaws. "
55 "You should therefore rely on anonymous objects and "
56 "signatures when designing your haXe remoting calls."}},
57 {li, [], {p, [], "A Yaws RPC handler can \"throw an exception\" "
58 "by returning {exception, Obj}, where Obj is any valid "
59 "haXe remoting value."}},
60 {li, [], {p, [], "haXe remoting has a few extra "
61 "values, expressed by the atoms 'infinity', 'neg_infinity' "
62 "and 'nan', corresponding to infinity, negative infinity "
63 "and 'not a number.'"}}
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
64 ]
65 },
66 {p, [], "Following is an example demonstrating the use of haXe "
0be3c7e @klacke untabified all of yaws
authored
67 "remoting in yaws. The first code segment is the haXe client "
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
68 "code, which invokes the 'echo' method in haxe_sample.yaws "
0be3c7e @klacke untabified all of yaws
authored
69 "and displays the result:"},
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
70 ss(A,"haxe_sample.html"),
71 {p, [], ["On the server side, we have the file haxe_sample.yaws "
0be3c7e @klacke untabified all of yaws
authored
72 "with the following code: "]},
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
73 ss(A, "haxe_sample.yaws"),
74
75 {p,[], "The two important lines on the server side are:"},
76 {ol,[],
0be3c7e @klacke untabified all of yaws
authored
77 [
78 {li,[],
79 {pre,[],"yaws_rpc:handler(A1, {haxe_sample, respond})."}},
80 {li,[],
81 {pre,[],"respond(State, {call, echo, Value} = _Request)"}}]},
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
82
7811247 @vinoski whitespace cleanup
vinoski authored
83 {p,[],
0be3c7e @klacke untabified all of yaws
authored
84 "The first line tells Yaws to forward all RPC calls (this "
85 "includes both haXe remoting and JSON RPC calls -- remember that "
86 "the yaws_rpc module handles both RPC mechanisms transparently) "
87 "to the \"respond\" function in the \"haxe_sample\" module. "},
88 {p, [],
89 "The second line tells Yaws to invoke this 'respond' function "
90 "when the client requests the method 'echo', while passing "
91 "the new state variable as the first argument to 'respond'. "
92 "You should duplicate this line for every RPC method you "
93 "wish to implement, replacing 'echo' with the method's name."},
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
94 {p, [],
0be3c7e @klacke untabified all of yaws
authored
95 "yaws_rpc optionally handles sessions for both JSON RPC and "
96 "haXe remoting. To use sessions, invoke yaws_rpc:handler_session "
97 "as shown in the JSON RPC documentation page."},
7811247 @vinoski whitespace cleanup
vinoski authored
98
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
99 {p, [],
0be3c7e @klacke untabified all of yaws
authored
100 "If the response is in the form of {exception, Obj}, "
101 "where Obj is any valid haXe remoting type, then the haXe client "
102 "will invoke the 'onError' handler, with Obj passed as the "
103 "parameter."},
104 {p, [],
105 "As with JSON RPC, both request and response values can be "
106 "composed of nested tuples of the form"},
107 box("{array, [Obj,...]}"),
108 {p, [], "and/or "},
109 box("{struct, [{prop, Val}...]}"),
110 {p, [], "Now go have fun! :)"}
1791e3d Added a haXe remoting adapter with documentation
Yariv Sadan authored
111 ]}},
112
113 {ssi, "END2",[],[]}
114 ].
115
116
117
118
119 </erl>
120
121
122
123
124
125
126
Something went wrong with that request. Please try again.