mirror of
https://github.com/ubf/ubf.git
synced 2026-04-21 20:25:57 +00:00
117 lines
6.4 KiB
HTML
117 lines
6.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<title>Module file_plugin</title>
|
|
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
|
|
</head>
|
|
<body bgcolor="white">
|
|
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
|
|
<hr>
|
|
|
|
<h1>Module file_plugin</h1>
|
|
<ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>UBF implementation (callback module) for a simple file server.
|
|
|
|
|
|
<h2><a name="description">Description</a></h2><p>UBF implementation (callback module) for a simple file server.</p>
|
|
|
|
<p>The original implementation of this module is Joe Armstrong's.
|
|
All of the EDoc commentary has been added to assist beginners in
|
|
understanding how to implement a UBF implementation/callback
|
|
module for a very simple stateful UBF protocol.</p>
|
|
|
|
This module can be used as a template for starting a new callback
|
|
module:
|
|
<ol>
|
|
<li> Create your protocol contract, e.g. <tt>myproto_plugin.con</tt> </li>
|
|
<li> Copy this file to a new name, e.g. <tt>myproto_plugin.erl</tt>. </li>
|
|
<li> Edit the <tt>-module</tt> line to use 'myproto_plugin'. </li>
|
|
<li> Edit the <tt>-add_contract</tt> line to use 'myproto_plugin'. </li>
|
|
<li> Change the <tt>info()</tt> and <tt>description()</tt> strings. </li>
|
|
<li> Most protocol implementations do not require changes to
|
|
<tt>managerStart()</tt> <tt>managerRpc()</tt>. </li>
|
|
<li> Edit <tt>handlerStart()</tt> to take care of any server-side
|
|
initialization/actions and private state required when a new
|
|
client connection is received. </li>
|
|
<li> Edit <tt>handlerStop()</tt> to take care of any server-side
|
|
clean-up details when a client connection is unexpectedly
|
|
closed. </li>
|
|
<li> Edit <tt>handlerRpc()</tt> to implement each of the RPC calls. </li>
|
|
</ol>
|
|
<h2><a name="index">Function Index</a></h2>
|
|
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#description-0">description/0</a></td><td>Mandatory callback function: Return description string.</td></tr>
|
|
<tr><td valign="top"><a href="#handlerRpc-4">handlerRpc/4</a></td><td>Mandatory callback function: process a single client RPC call.</td></tr>
|
|
<tr><td valign="top"><a href="#handlerStart-2">handlerStart/2</a></td><td>Mandatory callback function: New UBF connection handler.</td></tr>
|
|
<tr><td valign="top"><a href="#handlerStop-3">handlerStop/3</a></td><td>Mandatory callback function: a client session has been terminated.</td></tr>
|
|
<tr><td valign="top"><a href="#info-0">info/0</a></td><td>Mandatory callback function: Return info/version string.</td></tr>
|
|
<tr><td valign="top"><a href="#managerRpc-2">managerRpc/2</a></td><td>Mandatory callback function: Manager call handler.</td></tr>
|
|
<tr><td valign="top"><a href="#managerStart-1">managerStart/1</a></td><td>Mandatory callback function: Manager initialization function.</td></tr>
|
|
</table>
|
|
|
|
<h2><a name="functions">Function Details</a></h2>
|
|
|
|
<h3 class="function"><a name="description-0">description/0</a></h3>
|
|
<div class="spec">
|
|
<p><tt>description() -> string()</tt></p>
|
|
</div><p>Mandatory callback function: Return description string.</p>
|
|
|
|
<h3 class="function"><a name="handlerRpc-4">handlerRpc/4</a></h3>
|
|
<div class="spec">
|
|
<p><tt>handlerRpc(StateName::atom(), Call::term(), H_Data::term(), Env::term()) -> {term(), atom(), term()} | tuple()</tt></p>
|
|
</div><p><p>Mandatory callback function: process a single client RPC call.</p>
|
|
|
|
Valid return values are:
|
|
<ul>
|
|
<li> {Reply::term(), NewStateName::atom(), NewHandlerData::term()} </li>
|
|
<li> {changeContract, Reply, State1, HandlerMod, State2, Data2, ManPid} </li>
|
|
</ul></p>
|
|
|
|
<h3 class="function"><a name="handlerStart-2">handlerStart/2</a></h3>
|
|
<div class="spec">
|
|
<p><tt>handlerStart(ArgFromUbfClient::term(), ManagerPid::pid()) -> {accept, term(), atom(), term()} | {reject, term()}</tt></p>
|
|
</div><p><p>Mandatory callback function: New UBF connection handler.</p>
|
|
|
|
If the handler wishes to accept the connection, it returns the tuple:
|
|
<ul>
|
|
<li> 'accept' </li>
|
|
<li> Reply ... a term that is returned directly to the UBF client as
|
|
a response to the startSession() call. </li>
|
|
<li> HandlerState ... the initial UBF contract state name. </li>
|
|
<li> HanderData ... an arbitrary term to store this server's
|
|
private connection data. The word "state" is typically used
|
|
here, but the word "data" is used instead, to avoid confusion
|
|
between the "state" name of the UBF contract finite-state
|
|
machine and the "state" data for the connection handler. </li>
|
|
</ul></p>
|
|
|
|
<h3 class="function"><a name="handlerStop-3">handlerStop/3</a></h3>
|
|
<div class="spec">
|
|
<p><tt>handlerStop(Pid::pid(), Reason::term(), ManagerData::term()) -> term()</tt></p>
|
|
</div><p><p>Mandatory callback function: a client session has been terminated.</p>
|
|
|
|
The return value is the new manager private data term.</p>
|
|
|
|
<h3 class="function"><a name="info-0">info/0</a></h3>
|
|
<div class="spec">
|
|
<p><tt>info() -> string()</tt></p>
|
|
</div><p>Mandatory callback function: Return info/version string.</p>
|
|
|
|
<h3 class="function"><a name="managerRpc-2">managerRpc/2</a></h3>
|
|
<div class="spec">
|
|
<p><tt>managerRpc(X1::term(), State::term()) -> term()</tt></p>
|
|
</div><p>Mandatory callback function: Manager call handler.
|
|
</p>
|
|
|
|
<h3 class="function"><a name="managerStart-1">managerStart/1</a></h3>
|
|
<div class="spec">
|
|
<p><tt>managerStart(ArgFromMetaManager::term()) -> {ok, term()}</tt></p>
|
|
</div><p><p>Mandatory callback function: Manager initialization function.</p>
|
|
|
|
The term returned here is passed to the handlerStop/3 callback if a
|
|
client connection fails.</p>
|
|
<hr>
|
|
|
|
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
|
|
<p><i>Generated by EDoc, Apr 29 2009, 20:24:53.</i></p>
|
|
</body>
|
|
</html>
|