✨
This commit is contained in:
45
Assignment-3/buyer.ol
Normal file
45
Assignment-3/buyer.ol
Normal file
@ -0,0 +1,45 @@
|
||||
from SellerShipperServiceInterfaceModule import SellerInterface
|
||||
from BuyerServiceInterfaceModule import BuyerShipperInterface, BuyerSellerInterface
|
||||
|
||||
include "console.iol"
|
||||
|
||||
service BuyerService {
|
||||
execution { single }
|
||||
|
||||
outputPort Seller {
|
||||
location: "socket://localhost:9005"
|
||||
protocol: http { format = "json" }
|
||||
interfaces: SellerInterface
|
||||
}
|
||||
|
||||
inputPort ShipperBuyer {
|
||||
location: "socket://localhost:9003"
|
||||
protocol: http { format = "json" }
|
||||
interfaces: BuyerShipperInterface
|
||||
}
|
||||
|
||||
inputPort SellerBuyer {
|
||||
location: "socket://localhost:9004"
|
||||
protocol: http { format = "json" }
|
||||
interfaces: BuyerSellerInterface
|
||||
}
|
||||
|
||||
|
||||
|
||||
main {
|
||||
ask@Seller("chips")
|
||||
{
|
||||
[quote(price)] {
|
||||
if (price <20) {
|
||||
println@Console( "price lower than 20")()
|
||||
accept@Seller("Ok to buy chips for " + price)
|
||||
[details(invoice)]
|
||||
println@Console( "Received '"+invoice+"' from Shipper!")()
|
||||
} else {
|
||||
println@Console( "price not lower than 20")()
|
||||
reject@Seller("Not ok to buy chips for " + price)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user