Search in sources :

Example 1 with Bidding

use of org.jboss.quickstarts.websocket.model.Bidding in project quickstart by wildfly.

the class BidWebSocketEndpoint method onMessage.

// This method receives a Message that contains a command
// The Message object is "decoded" by the MessageDecoder class
@OnMessage
public void onMessage(Session session, Message message) throws IOException, EncodeException {
    if (message.getCommand().equals("newBid")) {
        Bidding bidding = BiddingFactory.getBidding();
        bidding.addBid(new Bid(session.getId(), message.getBidValue()));
    }
    if (message.getCommand().equals("buyItNow")) {
        Bidding bidding = BiddingFactory.getBidding();
        bidding.buyItNow();
    }
    if (message.getCommand().equals("resetBid")) {
        BiddingFactory.resetBidding();
    }
    notifyAllSessions(BiddingFactory.getBidding());
}
Also used : Bidding(org.jboss.quickstarts.websocket.model.Bidding) Bid(org.jboss.quickstarts.websocket.model.Bid) OnMessage(javax.websocket.OnMessage)

Aggregations

OnMessage (javax.websocket.OnMessage)1 Bid (org.jboss.quickstarts.websocket.model.Bid)1 Bidding (org.jboss.quickstarts.websocket.model.Bidding)1