1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
This example describes a way to develop client / server
applications.
There are three main ada units in this bank example. The "bank" that
manages the client accounts, a "manager" which loads the accounts from
a small database and provides some utilities and clients which modify
their accounts and transfer money from their account to the account of
someone else. This is always the same executable for the different
clients, but of course, they don't get the same partition id in order
to differentiate them.
--
To play with this example, you can do the following :
% gnatdist simcity
Open (at least) 3 sessions.
[On session 1, starts the scenario, load "example" database and print
the account status]
% bank_server
Menu :
Create
Load
Print
Quit
Save
Request : l
=> Load
Filename : example
Menu :
Create
Load
Print
Quit
Save
Request : p
=> Print
Customer : poor
Password : xxxx
Customer : 25
Customer : middle
Password : yyyy
Customer : 250
Customer : rich
Password : zzzz
Customer : 2500
Menu :
Create
Load
Print
Quit
Save
[On session 2, start the poor client]
% bank_client
Customer : poor
Password : xxxx
Balance : 25
Menu :
Balance
Deposit
Withdraw
Request : d
=> Deposit
Amount : 1000
Balance : 1025
Menu :
[On session 3, start the rich client and transfer money from rich to poor]
% bank_client
Customer : rich
Password : zzzz
Balance : 2500
Menu :
Balance
Deposit
Withdraw
Request : w
=> Withdraw
Amount : 1000
Balance : 1500
Menu :
Balance
Deposit
Withdraw
[On session 1, ask for the balances]
Request : p
=> Print
Customer : poor
Password : xxxx
Customer : 1025
Customer : middle
Password : yyyy
Customer : 250
Customer : rich
Password : zzzz
Customer : 1500
|