from SellerShipperServiceInterfaceModule import SellerInterface from BuyerServiceInterfaceModule import BuyerShipperInterface, BuyerSellerInterface include "console.iol" service BuyerService { execution { single } outputPort Seller1 { location: "socket://localhost:9005" protocol: http { format = "json" } interfaces: SellerInterface } outputPort Seller2 { 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@Seller1("chips") [quote(price1)] ask@Seller2("chips") [quote(price2)] if (price1 < 20 && price1 < price2) { println@Console( "price 1 lower than 20 and price 2")() accept@Seller1("Ok to buy chips for " + price1) reject@Seller2("Not ok to buy chips for " + price2) [details(invoice)] println@Console( "Received '"+invoice+"' from Shipper!")() } else if (price2 < 20 && price2 < price1) { println@Console( "price 2 lower than 20 and price 1")() reject@Seller1("Not ok to buy chips for " + price1) accept@Seller2("Ok to buy chips for " + price2) [details(invoice)] println@Console( "Received '"+invoice+"' from Shipper!")() } else { println@Console( "Both prices too high")() reject@Seller1("Not ok to buy chips for " + price) reject@Seller2("Not ok to buy chips for " + price) } } }