Files
2022B2-REB/Assignment-3/buyer.ol
NikolajDanger 51454e43a5
2023-01-13 14:43:05 +01:00

45 lines
1.0 KiB
Plaintext

from SellerShipperServiceInterfaceModule import SellerInterface
from BuyerServiceInterfaceModule import BuyerShipperInterface, BuyerSellerInterface
include "console.iol"
service BuyerService {
execution { single }
outputPort Seller {
location: "socket://localhost:9007"
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)
}
}
}
}
}