commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qin ding <>
Subject [scxml] passing data to the state
Date Mon, 12 Jul 2010 16:49:41 GMT
I am learning commons scxml.  I am experimenting writing a poker game using 
activemq and scxml.  

So, I have my config xml defined as follows:

<?xml version="1.0"?>
<scxml xmlns=""
        <data name="inputPlayer">
          <!-- Note namespace declaration in line below -->
          <player xmlns="">
    <state id="waitingRound">
        <!-- shuffle deck and check players and empty pot -->
        <transition event="game.start" target="preflopRound"/>
    <state id="preflopRound">
        <!-- place small/big blinds in pot and deal each player two hole cards 
        <transition target="firstBettingRound"/>
    <state id="firstBettingRound">
        <transition event="game.flop" target="flopRound"/>
        <transition event="game.showdown" target="showdownRound"/>
    <state id="flopRound">
        <!-- deal three cards in the community -->
        <transition target="secondBettingRound"/>
    <state id="secondBettingRound">
            <var name="inputPlayer" expr="#{request$player}" />
        <transition event="game.turn" target="turnRound"/>
        <transition event="game.showdown" target="showdownRound"/>
    <state id="turnRound">
        <!-- deal a 4th card in the community -->
        <transition target="thirdBettingRound"/>
    <state id="thirdBettingRound">
        <!-- deal a 4th card in the community -->
            <var name="inputPlayer" expr="#{request$player}" />
        <transition event="" target="finalRound"/>
        <transition event="game.showdown" target="showdownRound"/>
    <state id="finalRound">
        <!-- deal a 5th card in the community -->
        <transition target="finalBettingRound"/>
    <state id="finalBettingRound">
        <!-- bet, check, call, raise, or fold -->
            <var name="inputPlayer" expr="#{request$player}" />
        <transition event="game.showdown" target="showdownRound"/>
    <state id="showdownRound">
        <transition event="game.reset" target="waitingRound"/>

My questions:  
How can I pass my pojo "Player" to the firstBettingRound, secondBettingRound and 
etc? This player object is coming from game client with betting information.  

After the activemq delivers it to the server end,  how can I know which method 
to call?  I think scxml handles the the state of game, so I have to say

Set states = getEngine().getCurrentStatus().getStates();
        return ((org.apache.commons.scxml.model.State) states.iterator().

if the current state is firstBettingRound,  I do 
game.firstBettingRound(player);  Is it correct

I seem unable to find the example to show me how to pass pojo to the state 
correcponded method.  If I am completely wrong with my approach, Please advise.  
Thank you very much.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message