Here I am again with EVO (ExtendedVisualOtp)
Ivan Carmenates García
ivan060111ad@REDACTED
Fri Nov 5 17:24:58 CET 2010
*ExtendedVisualOtp*
*(EVO)*
*The User's Guide*
*Version 1.4*
Ing. Ivan Carmenates García
Ivanco Software Company in association with SPI Team
November 3 2010
Index
Abstract 5
Introduction. 6
Content 13
Functionalities of the ExtendedVisualOtp.dll library. 13
ConvertToCSharp: 13
· FromErlangObject(Otp.Erlang.Object _object) 13
· FromErlangReply(Otp.Erlang.Object _replyObject) 13
ConvertToErlang: 13
· ToErlangObject(object _object) 13
· ToErlangObjectFromString(string _object) 13
ErlangServerInterface: 13
· AutoTrace. 13
· Connect() 13
· ErlangCookie. 13
· Disconnect() 13
· IsConnected. 13
· OnDisconnected(IServerReply _reason) 14
· OnReceive(IServerReply _reply) 14
· PingTimeOut 14
· RemoteAddress. 14
· RemoteNodeName. 14
· RemoteProcessName. 14
· SetOwnerForm(Form _ownerForm) 14
· SentToErlangServerRequest(ErlangServerRequest
_erlangServerRequest, IServerReply _reply) 14
· ServerPort 14
· StartEVOTestApplication() 14
· UseShortNames. 14
· AllowReceiveClientImage. 14
ErlangServerRequest: 15
· AbortAllRequests() 15
· AbortAsyncRequests() 15
· AbortNormalRequests() 15
· AbortRequest(IRequestInfo _reqInfo) 15
· Description. 15
· Message. 15
· ErlangServerInterface. 15
· OnReceive(IServerReply _reply) 15
· Request(string _description, object _message) 15
· RequestAsync(string _description, object _message) 15
· Request(object _message) 15
· RequestAsync(object _message) 15
· SetOwnerForm(Form _ownerForm) 16
· PublishClientImage() 16
IRequestInfo: 16
· AbortRequest() 16
· Description. 16
· Kind. 16
· WaitForReply() 16
· WaitForReply(int _timeout) 16
· WasAnswered. 16
· WasMade. 16
IServerReply: 16
· CSharpReply. 16
· Description. 16
· ErlangReply. 16
· RequestInfo. 16
RequestKind. 17
· Async. 17
· Normal 17
· ServerSent 17
The evo_template template. 18
The evo_template has many files listed at following: 18
· 1.install.cmd. 18
· 1.start.cmd. 18
· 2.service_install-start.cmd. 18
· 2.service_stop.cmd. 18
· 2.service_uninstall.cmd. 18
· compile.cmd. 18
· config.cmd. 18
· Folder [beam] 18
· appname.app. 18
· appname.beam.. 18
· appname_debug_module.beam.. 18
· appname_main_interface.beam.. 18
· appname_main_supervisor.beam.. 18
· Folder [sources] 18
· appname_db_module.erl 19
· appname_db_server.erl 19
· appname_request_handler.erl 19
The Big Example. 22
Annexes. 26
Conclusions. 29
Abstract
The ExtendedVisualOtp (EVO) is a component specialized in client-server
communication, implemented in two programming
languages, C# of Microsoft and Erlang of Ericsson, oriented to the
development of real time applications, where the server
applications are written in Erlang and the client applications in .Net.
The main concept of this component is the
development of client-server applications where the productivity factor
is highest and the cost of the production is quite
low. Ideal for small companies with few experience in that kind of
applications, which want to insert into this so wide
world that is the interaction and exchange of information through the
network, in a fast and powerful manner.
Introduction
The ExtendedVisualOtp (EVO) is a component specialized in client-server
communication, implemented in two programming
languages, C# of Microsoft and Erlang of Ericsson, oriented to the
development of real time applications, where the server
applications are written in Erlang and the client applications in .Net.
The main concept of this component is the
development of client-server applications where the productivity factor
is highest and the cost of the production is quite
low. Ideal for small companies with few experience in that kind of
applications, which want to insert into this so wide
world that is the interaction and exchange of information through the
network, in a fast and powerful manner.
It can be illustrated through a simple example:
Example #1: Imagine you want to develop a small client application, so
you want to make a request "know my payment" to
a server application and to be notified about the answer generated by
that request.
Develop this simple example in any programming language without the
usage of a helper component, could represent a lot
of work. However, using the ExtendedVisualOtp.dll library for the
development of client applications and the evo_template
template to write server applications becomes from a large and restless
work to a simple and comfortable one.
Answer for the example #1 using EVO
At the client application, after a few and simple visual configurations
for the ErlangServerInterface and
ErlangServerRequest components of the ExtendedVisualOtp.dll library, you
should write:
// to connect to the server
erlangServerInterface1.Connect();
// to make a request
erlangServerRequest1.Request("Description of the request", object _message);
or
erlangServerRequest1.Request(object _message);
NOTE:
* Request-OnReceive means the OnReceive event of the
ErlangServerRequest component.
* Interface-OnReceive means the OnReceive event of the
ErlangServerInterface component.
// to receive the answers
The answers of the made requests could be caught of Async way through
the Request-OnReceive event, or could be caught
of Sync way using the function WaitForReply() immediately after the
request, example for the Sync way:
IRequestInfo reqinfo = erlangServerRequest1.Request("knows the salary",
new object[] {
" 'know_my_payment' ", "Ivan Carmenates García"});
IServerReply reply = reqinfo.WaitForReply();
MessageBox.Show(reply.CSharpReply.ToString());
reqinfo is an object of the class or interface IRequestInfo. It contains
the information of the made request, allowing
to do some stuffs with it, such as, block the program, to wait for the
answer, reqinfo.WaitForReply(), or abort the made
request, reqinfo.AbortRequest().
reply is an object of the class or interface IServerReply that contains
the information to treat the answer sent by the
server.
In case that you wish to receive the answers using the Async way, you
must use the Request-OnReceive event without the
usage of the function WaitForReply(), example for the Async way:
IRequestInfo reqinfo = erlangServerRequest1.Request("knows the salary",
new object[] {
" 'know_my_payment' ", "Ivan Carmenates García"});
And to receive the answer, you should write something like this:
OnReceiveErlangServerRequestMethodNameHere(IServerReply _reply)
{
switch(_reply.Description) {
case "knows the salary":
MessageBox.Show(_reply.CSharpReply.ToString());
break;
}
}
The same implementation, works for receive all the answers of all
requests that you make, you just have to add a new
clause to the switch sentence with a new description, a description per
request you make.
So, to write server applications, you must edit the server template,
evo_template and in the file called
evo_request_handler.erl, located in the sources folder, about the line
28, part: [USER FUNCTIONS TO MODIFY] write your
code. For the case of example #1, could be:
{{know_my_payment, Name}, Pid, RequestInfo}->
Reply = evo_db_module:get_payment (Name), %% this function is
implemented in other module.
Pid ! {reply, Reply, RequestInfo};
As it seems, is easy to write client-server applications in EVO. If
you're wandering, how it is possible? The answer
is as simple as it sound, that's all! The EVO component, in its total
integrity, both, the template evo_template to
develop server applications and the ExtendedVisualOtp.dll library to
develop client applications, it handles for you
all the dirty work. You just have to abstract your mind to the existence
of a fast and efficient postman, which you
call to deliver your letter or messages to a given destination, in this
case the server. The server can send if you
wish, the message to all other people in the "world", or just to one
person, if it is programmed of that way, acting
as intermediary. An example, if you wish to send "directly" a message to
another client, the EVO component has a
functionality, where once your client is connected to the server, each
time that other clients get connected or
disconnected, the server sends to your client a notification message of
new client connected, {new_member, Pid}, or
client disconnected, {crashed_member, Pid}, and the ID or address Pid.
With this ID, you can send to those clients
through the server a message, simple as it may seem! Making a request
like this:
IRequestInfo reqinfo = erlangServerRequest1.Request(new object[] {
" 'send_to' ", ClientPid, Message});
Notice here the usage of the other way to make requests to the server,
where is not necessary to specify a description
for the request, it is the case of the call to the function
Request(object _message). The description for this request
is obtained by the first element inside the message, if the message is
an array or a list of elements and if its first
element is an Erlang atom, or if the message is just one element and it
is an Erlang atom. For the case before, note
that the first element of the array that you send as message is the
Erlang atom " 'send_to' ". This atom is the
description for the request and the message at the same time. In case
that the first or unique element of the message
isn't an Erlang atom, the description for the request will be set to the
Erlang atom " 'no_description' ".
How to catch the message {new_member, Pid} / {crashed_member, Pid}?
Through the Interface-OnReceive event, example:
OnReceiveErlangServerInterfaceMethod(IServerReply _reply)
{
If (_reply.Description == "new_member") {
erlangServerRequest1.Request(new object[] {
" 'send_to' ", _reply.ErlangReply as Otp.Erlang.Pid, "Are
you new?"});
}
}
With this, your client sends to each client that got connected to the
server, the message: "Are you new?"
_reply.ErlangReply, it's the message, that is, the ID of the client
recently connected to the server.
On the server application, in the template evo_template to develop
server applications, in the file,
evo_request_handler.erl, you should write something like this:
%% The 'send_to' message.
{{send_to, WhoPid, Message}, Pid, RequestInfo = {Description, _, _, _, _}}->
send_to(WhoPid, Description, Message),
Pid ! {reply, "The message was successfully sent.", RequestInfo};
The function send_to(ClientPid, Description, Message) is a function that
comes within the component EVO, in the template
for server applications, evo_template, with which you can send messages
to any client that got connected to the server,
specifying its id (Pid) in the connection.
The Interface-OnReceive event is fired each time that any message sent
by the server, is received on the client. And the
Request-OnReceive event is fired only when a message received, is the
answer of a request made by it. So if you want to
get low level messages, you must use the Interface-OnReceive event.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20101105/88b90c8d/attachment.htm>
More information about the erlang-questions
mailing list