Optimal communication strategy for poker game

Hi,
I'm designing a client/server poker game, and I'm trying to decide on the best protocol for client/sever comms. It's a personal project, so it doesn't need to be 100% robust or extensible.
I was thinking of the following model:
Client(s) and server communicate via Object Input/Output Streams over a socket. Client opens a Listener thread which listens in a while(true) loop, and Server also listens in a while(true) and processes incoming messages. The communication workflow will follow a request-response model.
I will create my own Message class(String sender, int msgType, Object msgValue), and both listening classes will use switch(msgType) statements to process requests.
Does anybody have any recomendations/stipulations regarding this model? There are a couple of issues I can think of:
1. Use of while(true) loops should be avoided
2. What happens to forever-listening ObjectInputSrteams when the client disconnects unsafely?
3. How should the server handle client disconnects? Is it sufficient to use the onWindowClose method in the client GUI?
Any feedback appreciated, thanks in advance,
Sean

Why not use RMI instead of plain sockets? The server part can be a
simple facade to the real poker server (which can be a simple POJO).
The 'business logic' (the poker game itself) is handled by the real
poker server while all communication stuff is handled by RMI. That way
the clients don't have to be aware of the fact that they're talking to some
thing remote and it frees you from implementing that communication
layer with all its burden.
kind regards,
Jos

Similar Messages

  • HOW to make 2 step Communication strategy  for external send

    Hi
    I have made this 2 step communication strategy and attached to an email output type for purchase order, but it doesn't work as expected.
    The 2 steps are 1  INT,  2 = PRT
    If the vendor/supplier has an email in the address the purchase order is send by email, but if he has no email addres, then the output fails with message "E-mail address incorrect or non-existent"
    I expected the result to be that it would create a print instead of an email.
    What is wrong?
    Thanks.
    Thomas Madsen Nielsen

    I found the solution myself.
    The communication type PRT = Print is not supported, but LET = Letter will do exactly the same thing.
    I found the answer in OSS note 323720.
    Thanks

  • Rolling Images for poker Game

    Hello everybody,
    i m trying to make poker game in java. it is some what like this, there will three labels which will show continuos scrolling images or numbers. there will a button "HIT" button to stop moving images.after that those images will stop one by one.if all images are same then he will get message of congratulation. first of all i m trying to show numbers in labels. but it should look like it is rolling. with settext method it is directly printing the number. can anybody suggest me how to print number in Jlabel with rolling effect? . Thanks in advance

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    public class SpinningGeeks extends JPanel implements ActionListener,
                                                         Runnable {
        BufferedImage image;
        Rectangle[] rects;
        int[] yPos;
        int dy = 3;
        Random seed = new Random();
        boolean[] runs = new boolean[3];
        Thread thread;
        long delay = 25;
        boolean stopping = false;
        public void actionPerformed(ActionEvent e) {
            String ac = e.getActionCommand();
            if(ac.equals("START"))
                start();
            if(ac.equals("STOP"))
                stopping = true;
        public void run() {
            int[] ds = new int[yPos.length];
            for(int j = 0; j < yPos.length; j++) {
                ds[j] = dy -1 + seed.nextInt(3);
            int runIndex = 0;
            boolean countingDown = false;
            long time = 0;
            while(runs[runs.length-1]) {
                try {
                    Thread.sleep(delay);
                } catch(InterruptedException e) {
                    break;
                if(stopping && !countingDown) {
                    int remainder = yPos[runIndex] % rects[runIndex].height;
                    boolean atEdge = remainder < ds[runIndex]/2;
                    if(atEdge) {
                        // Stop here, start waiting 2 seconds before
                        // moving on to stop the next image.
                        countingDown = true;
                        time = 0;
                        runs[runIndex] = false;
                        runIndex++;
                        if(runIndex > runs.length-1) {
                            continue;
                } else if(countingDown) {
                    // Wait 2 seconds before stopping the next image.
                    time += delay;
                    if(time > 2000) {
                        countingDown = false;
                // Advance all images that have not been stopped.
                for(int j = 0; j < yPos.length; j++) {
                    if(runs[j]) {
                        yPos[j] += ds[j];
                        if(yPos[j] > image.getHeight()) {
                            yPos[j] = 0;
                repaint();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            int pad = 5;
            int x = (getWidth() - (3*rects[0].width + 2*pad))/2;
            int y = (getHeight() - rects[0].height)/2;
            for(int j = 0; j < rects.length; j++) {
                rects[j].setLocation(x, y);
                x += rects[j].width + pad;
            Shape origClip = g2.getClip();
            for(int j = 0; j < yPos.length; j++) {
                x = rects[j].x;
                y = rects[j].y - yPos[j];
                // Comment-out next line to see what's going on.
                g2.setClip(rects[j]);
                g2.drawImage(image, x, y, this);
                if(yPos[j] > image.getHeight() - rects[j].height) {
                    y += image.getHeight();
                    g2.drawImage(image, x, y, this);
            g2.setClip(origClip);
            g2.setPaint(Color.red);
            for(int j = 0; j < rects.length; j++) {
                g2.draw(rects[j]);
        private void start() {
            if(!runs[runs.length-1]) {
                Arrays.fill(runs, true);
                stopping = false;
                thread = new Thread(this);
                thread.setPriority(Thread.NORM_PRIORITY);
                thread.start();
        private void stop() {
            runs[runs.length-1] = false;
            if(thread != null) {
                thread.interrupt();
            thread = null;
        private JPanel getContent(BufferedImage[] images) {
            // Make a film strip assuming all images have same size.
            int w = images[0].getWidth();
            int h = images.length*images[0].getHeight();
            int type = BufferedImage.TYPE_INT_RGB;
            image = new BufferedImage(w, h, type);
            Graphics2D g2 = image.createGraphics();
            int y = 0;
            for(int j = 0; j < images.length; j++) {
                g2.drawImage(images[j], 0, y, this);
                y += images[j].getHeight();
            g2.dispose();
            // Initialize clipping rectangles.
            rects = new Rectangle[3];
            for(int j = 0; j < rects.length; j++) {
                rects[j] = new Rectangle(w, images[0].getHeight());
            // Initialize yPos array.
            yPos = new int[rects.length];
            for(int j = 0; j < yPos.length; j++) {
                yPos[j] = 2*j*images[0].getHeight();
            return this;
        private JPanel getControls() {
            String[] ids = { "start", "stop" };
            JPanel panel = new JPanel();
            for(int j = 0; j < ids.length; j++) {
                JButton button = new JButton(ids[j]);
                button.setActionCommand(ids[j].toUpperCase());
                button.addActionListener(this);
                panel.add(button);
            return panel;
        public static void main(String[] args) throws IOException {
            String[] ids = { "-c---", "--g--", "---h-", "----t", "-cght" };
            BufferedImage[] images = new BufferedImage[ids.length];
            for(int j = 0; j < images.length; j++) {
                String path = "images/geek/geek" + ids[j] + ".gif";
                images[j] = javax.imageio.ImageIO.read(new File(path));
            SpinningGeeks test = new SpinningGeeks();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test.getContent(images));
            f.add(test.getControls(), "Last");
            f.setSize(400,300);
            f.setLocation(200,200);
            f.setVisible(true);
    }geek images from [Using Swing Components Examples|http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html]

  • Communication strategy missing for external send

    Dear all,
    I want to send O/Cs via mail, therefore I configured the transmission medium of the output type to "external send". As well I set the communication strategy for mail to the output type. Nevertheless I receive an error, when I want to save the O/C with a new message. Please be so kind and take a look at the attached screenshot. Do you have any idea why the error occurs?
    Best regards,
    Benjamin

    Hi Susan,
    Please be so kind and take a look at the SAP-note 2017440 - Communication strategy cleared in message output  . In my case this solved the problem.
    Best regards,
    Benjamin

  • Communication Strategy Message no. TK455

    Hi Guru,
    I'm creating the Communication Strategy for PO to send out via Email.
    I get the following error message. Please help. Thanks.
    Message no. TK455
    Diagnosis
    The value " " was entered in the field "POS".
    This is not possible because it is a numeric field where only numbers may be entered.
    The length of the field is 000002.
    System Response
    The entry was not accepted.
    Procedure
    Enter only numeric values in this field.

    Visit following path -
    SPRO -> IMG -> SAP Web Application Server -> Basic Services -> Message Control -> Define Communication Strategy.
    Here communication strategy CS01 should be available. You may check the settings. This should include Medium 5 (external sending).
    Use the standard SAP environment (program 'SAPFM06P', FORM routine 'ENTRY_NEU' and form 'MEDRUCK') as the processing routines.
    Maintain email address in vendor master data.
    Regards
    Rajesh

  • HT203433 I want to buy chips for a poker game and it keeps telling me to visit itunes/support

    I want to buy chips for a poker game and it keeps telling me to visit www.apple.com/support/support/itens/ww/. My credit card doesn't have a hold and it is a good credit card.  please someone help

    You need to contact itunes support.

  • How to find a good AI strategy for a survival game?

    Hi, I'm a college student here developing a tank survival game for the finals. I have had very little experience in AI strategies, so I wonder if anyone here can give me a hint or two to start.
    Thanks.
    The game's description is below:
    Goal:
    Develop a good AI strategy for survival.
    ������������������������������������������������������������������������������������������
    Game Name: Tank Survival
    How game starts: All tanks will be placed on the board in random position
    How game ends: When we have only one tank surviving, that's the winner
    When does a tank die? When the energy of a tank is zero, it dies.
    Game environment: A 15x15 closed environment, like a chess board
    Participants: 5 teams, 3 tanks per team
    ������������������������������������������������������������������������������������������
    Game Basic Rule
    For each tank, only 1 action is allowed each turn.
    A tank can move with a shield on, but shield costs energy.
    When one tank destroyed another one, it takes all the energy left of the victim
    tank. *(Bonus from kill � 1000 + (1/2)*Enemy energy before kil)
    The tank's weapon can only shoot in continuous linear way.
    ������������������������������������������������������������������������������������������
    Facts about the tank
    Initial Tank Energy - 10000
    Life Support Energy cost �- 50
    Missile yield multiplier - � 3
    Shield multiplier - � 5
    Radar Cost = [(distance * accuracy) ^1.3] * 3 + 100
    Missile Cost � yield + accuracy * distance * 7
    Movement Cost = (distance^1.4) *50
    Shield Cost = multiplier * Energy shielded
    Maximum movement - distance � 5 (any direction)
    Bonus from kill -� 1000 + (1/2)*Enemy energy before kill
    Missile accuracy -� not disclosed
    Radar Accruacy �- not disclosed
    ������������������������������������������������������������������������������������������
    Key problems
    � I only have 3 tanks. . .
    � I have to survive among the other 15 tanks.
    � None of the actions, misile, radar, or shield are 100% working. There are always chances that they don't work.

    I think the first stage is to work out what constitutes a "state" and a "move." A state is the current board positions with all the tank energies and other parameters. A move is a transition from one state to another. Can you move around? Can you fire the gun and move the tank at the same time? If you fire the gun, does it miss sometimes?
    You then have to have a way to evaluate a state. For instance, if you move closer to an enemy tank, does that put you in a better position or a worse position?
    You can then draw a Moves Tree. This starts from where you are, shows all the moves you could make and the states you could end up in after one move. You can attach a value to each state.
    Then you can extend the state tree by adding all the counter moves your enemy could make, and the states in which those moves would leave the game. Thus the transition from your state now, to your state after the enemy has moved, will show a gain or a loss, depending on whether you or the enemy gained more or lost less.
    The strategy that wins the game will be the one that takes you from the start state to the goal state in such a way that your enemy cannot stop you. There are two possible strategies for choosing moves, Minimax and Maximin. Minimax means minimise your maximum loss; Maximim means maximise your minimum gain.
    Try it first with a simple game like Nought and Crosses. The state tree grows very rapidly in the number of moves, so you may need some algorithm for pruning it or for generating only part of it at a time, as modern chess playing algorithms do.
    Write in a computer language that is good at handling state trees. I used to use Prolog but some programmers swear by Lisp. You won't be able to solve the problem in a crap language like Basic, Pascal or anything like those.
    You will need to read around the subject. If Alan Bundy has written anything recently, look at that first: he is an excellent writer and a very skilful practitioner as well.

  • Wanting to make a poker game for a message board

    I'm trying to start a java app that will be a poker game (texas holdem) where members of a message board can join and play each other. Is there a good tutorial on how to embed this type of project into a message boar/forum?
    thanks for any information.

    Most message boards use some kind of server side technology (servlet, jsp, asp,...) and most games use some kind of client side technology (applets, activex,...), so there's probably not a lot out there about it. It should be possible and sounds kind of interesting though.

  • Using VMWare Fusion for playing games

    Hi all and I hope you can help.
    I have a recent 17" MBP with 2GB of RAM and a Core 2 Duo and I am trying to get some decent game software running on it. To do this I have installed VMWare Fusion, XP Pro and Crysis.
    My problem is, I can get the game to run but it is VERY choppy and unplayable.
    I have tried various virtual settings, including using 1 and 2 processors, 512mb to 1.5gb RAM but never getting it to run properly.
    I am not trying to run it full screen or anywhere near high settings and have allowed the game to scan the hardware to find it's optimal settings and still no luck.
    I know Crysis is quite a heavy load but with the hardware in an MBP it should be able to run it without many problems.
    Am I being too optimistic trying to run Crysis or are there a set of parameters that are optimised for doing this?

    VMWare will also allow you to virtualize a boot camp partition.
    The problem with virtualization and gaming is that, while you get direct CPU access and protected memory access, you do not get video access - so there is absolutely no video acceleration, it's all emulated or translated by the virtualizer.
    You'll see a very minor CPU hit on anything that just using processor power or takes a lot of data (so long as you have enough physical RAM, and have enough RAM allocated to the virtual machine, to prevent disk swapping), but anything that needs video acceleration will suffer tremendously if it's virtualized.
    In general, anything more than Solitare or Minesweeper, and you will want to use Bootcamp if there is no Mac OS X native version of the game (hooray for Blizzard, and all you other mac-native developers). I know the latest versions of VMWare and Parrallels all say they have new DirectX support, and Crossover has a version out just for gaming, but you'll disappoint yourself if you think these will do much more than just show the splash screen and a slide show for most games.
    The good news is more game companies are starting to take Mac OS X seriously, and technologies such as Cider are helping developers port their code easier. But it's a long road, and the Macintosh has notoriously been spotty for gaming.

  • Urgent complaint against the company for the game (Call of War 2)

    HI Apple Customer
    I want to lodge a complaint against the company for the game Call of War 2 where they were paid large sums of money to buy gold from within the game , and the problem is that the game does not work properly in this talk to my complaint on behalf of a lot of people affected by this game
    The beginning of my problem with them is that I paid $ 10 dollars to buy gold from within the game and did not I receive gold and filed a complaint and you 've Pthoila link to the company and the amount demanded , but did not recover to now
    Second, you then ship went at least $ 200 in order to increase my points within the game , but what happened unlooked
    Where she lost a lot of points in the game through suspension compulsory in the game during the winning entry for the battle where the message appears ( There was an error in the game and is being re- loaded (
    Causing heavy losses to me where I went in the amounts paid by the wind
    I am not the only one suffering from this problem , but all the players in the game and what they are Arabs and our own website in English , they do not know how to make a complaint to you
    Of the problems that I face when I entered I battle to download and try to destroy the enemy soldiers and earn points .. got an error message appears and the game is being re- uploaded because of this and lost a lot of points
    In contrast, the enemy attacked by Ali and win and take the points, losing my points from both sides , not only one side
    To prove that you have attached pictures
    In addition to this when my complaint is they do not respond quickly , and that was answered say that Gary solve the problem for them and what has not been nearly two weeks to solve the problem
    The tickets are closing the complaint without my consent and my advice so
    Lost in the game nearly 100 points and lost a lot of mattresses because of their problems and in spite of my claim Ptaubi but they do not care about it any attention , where only care about attracting players to buy gold through without paying attention to the daily announcements technical support and solving problems of the game
    Picture number one shows the attack, which I've done and lost it , and the reason is that the game is stopped and failed landing soldiers what caused the loss of points
    The second picture shows the defense so that also lost a lot of points
    I can not attack while the other players came to heavy losses and lost
    I hope compensatory and accounting problems that the company did not end
    And to you my thanks and appreciation

    Please be aware that you are not communicating with Apple when you post in these forums. These are user-to-user support forums, so in almost all cases the only people who will reply to your posts are, like me, your fellow users.
    As to your issue with this game, go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • Release strategy for PO on Payment terms..

    Dear friends,
    Is it possible to have Release strategy for PO on Payment terms.....
    I checked in CEKKO, no field availble for payment terms.
    Is there any other way..........
    Plz help
    Rgds,
    Navin

    Hi,
    You can append Communication Structure "CEKKO" and add Payment Term (ZTERM)
    Use User Exit "M06E0004" (Changes to communication structure for release purch. doc.)
    Function module "EXIT_SAPLEBND_002" (Changes to Communication Structure for Release of Purchasing)

  • Release strategy for RFQ

    Hi,
    Please let me know,how to set release strategy for rfq.. i'VE ACTIVATED MY RELEASE STRATEGY FOR po USING TABLE cekko... iF I WANT TO ACTIVATE RELEASE STRATEGY FOR rfq... WHICH TABLE AND FIELD NAME I WANT TO USE... PLS EXPLAIN..

    For RFQ also we can use the same communication structure CEKKO, but for differentiation between release startegy of Contrcats Purchase orders & RFQ's better to use the Charcteristic Document category i.e CEKKO - BSTYP - Purchasing Document Category

  • Request for optimal calibration settings for Lenovo ThinkVision monitors

    I understand one person's settings may not hold true for someone else's given display variances, but I would very much like to get anyone's suggested, optimal picture settings for each of the below two monitors.
    Primarily monitor 1 looks way worse than monitor 2 for me, but I still want help with both.  Models listed below.  Please include each item/setting with # used so I can try them out and see if it helps.
      Monitor 1: LEN L1900pA
      Monitor 2: LEN LT1913pA
    Thank you for your help!

    Hi Jwhyrock,
    Jwhyrock reply,
    I played with settings on all 3 monitors.  Not entirely sure I like what I did, but it is a bit better.  I would still like to see what settings anyone else is using for their display such as contrast, brightness, color saturation etc.
    Below is the link on how to setup the default calibration for display, please follow the steps. And also suggest you to check with resetting the Monitor to factory default setting in the monitor, or you can also check with installing Monitor .inf for the specific model which can be downloaded from the manufacturer link.
    Display Calibration
    Hope this helps!
    Best regards,
    Hemanth Kumar
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • No release strategy for service PO

    Purchasing document xxxxxxx cannot be released
    Message no. MEPO823
    I created release strategy for service entry sheet through following process.
    1. Created three characterstics(service_val, serv_plant & ZSER_DOC TYPE) and assigned it to class 032 (gave it name service entry sheet) Communication structure CESSR and fields WERKS etc...
    2. Than maintained all the config setting for service entry sheet through External service management..Maintained release groups, release codes, release strategy and r and maintained all the values .
    3.I made a service PO with doc type FO
    Now i dont get a tab of release on the service PO tab and get the above error.
    Just let me know step by step how to config release strategy for service entry sheet.Do we need to maintain all above entries...?
    For PO we have release strategy maintained for all document types and i am able to release the PO.
    Regards,
    Shailendra

    Keep the release strategy at Plant level only....All the purchasing docs will get blocked

  • Poker game experiencing lag problems

    I've recently written a semi-functional Poker game however I'm experiencing problems with the game slowing down drastically as game play continues. I only have some basic high school programming knowledge so please forgive me for my extremely poor coding practice. Included are are the source files and jar. Any help would be appreciated. Thanks

    Ducky24 wrote:
    Upon using the Net Beans profiler I am finding myself quite shocked. The results show that invoke my formatJButton some 181000 times however I have no idea why it is invoked such.You have your swingComponent() method being called from inside of your paintComponent() method, and that seems like a bad idea to me. Every time your screen redraws, it will call this method, and it seems to me that it should be the other way around -- Your swingComponent should be involved with changing things and then call revalidate() and repaint() to relayout and redraw things.
    Again, I can't force myself to look at all of your code, but I wonder if you should be using a CardLayout here to swap JPanels rather than removing and repositioning and such.

Maybe you are looking for

  • Query for Sales Order Analysis

    Dear Experts I have written a Query for Sales Order Analysis and would like to have help on this. The query is used for generating daily report for Sales Order on number of documents (Sales Order), total amount of sales orders and total GP of Sales O

  • Error 48 when installing creative cloud for desktop on mac

    hi jeff when installing creative cloud for desktop we have this problem, tried everything but no success on mac osx lion  the message that gives creative cloud for desktop app on installing is this: error code 48, a critical file/directory can't be a

  • Mail received on iPhone but not Macbook Pro

    I use godaddy as my domain host. Just today I noticed that when I click the button to get new messages in Mail, the activity light indicates that messages are being loaded, but nothing actually comes in. All incoming emails are received on my iPhone.

  • Servlet connection to mssql

    i want to connect servlet to mssql database on server.....i hv already created database from mssql server 2005....i hv written code for servlet.....but i dint getting wht should i write in Class.forname(); wht will be the URl also.....i hv sqljdbc.ja

  • Bluetooth connected phone call waits until the person answers to connect through speakers! How to change this.

    When placing a bluetooth call the car shows that the phone is connected but there is no ringing (it is still ringing in the phone speaker).  Then the person answers and it plays through the car speaker, but misses the first word.  What is happening?