EMMA Coverage Report (generated Mon Jul 11 13:15:38 KST 2005)
[all classes][org.apache.mina.examples.tennis]

COVERAGE SUMMARY FOR SOURCE FILE [TennisPlayer.java]

nameclass, %method, %block, %line, %
TennisPlayer.java0%   (0/3)0%   (0/9)0%   (0/117)0%   (0/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TennisPlayer0%   (0/1)0%   (0/3)0%   (0/16)0%   (0/5)
TennisPlayer (): void 0%   (0/1)0%   (0/9)0%   (0/3)
getCodecFactory (): ProtocolCodecFactory 0%   (0/1)0%   (0/4)0%   (0/1)
getHandler (): ProtocolHandler 0%   (0/1)0%   (0/3)0%   (0/1)
     
class TennisPlayer$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class TennisPlayer$TennisPlayerHandler0%   (0/1)0%   (0/6)0%   (0/101)0%   (0/18)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/1)
TennisPlayer$TennisPlayerHandler (): void 0%   (0/1)0%   (0/10)0%   (0/2)
messageReceived (ProtocolSession, Object): void 0%   (0/1)0%   (0/44)0%   (0/9)
messageSent (ProtocolSession, Object): void 0%   (0/1)0%   (0/16)0%   (0/2)
sessionClosed (ProtocolSession): void 0%   (0/1)0%   (0/14)0%   (0/2)
sessionOpened (ProtocolSession): void 0%   (0/1)0%   (0/14)0%   (0/2)

1/*
2 * @(#) $Id: TennisPlayer.java 210062 2005-07-11 03:52:38Z trustin $
3 */
4package org.apache.mina.examples.tennis;
5 
6import org.apache.mina.protocol.ProtocolCodecFactory;
7import org.apache.mina.protocol.ProtocolHandler;
8import org.apache.mina.protocol.ProtocolHandlerAdapter;
9import org.apache.mina.protocol.ProtocolProvider;
10import org.apache.mina.protocol.ProtocolSession;
11 
12/**
13 * A {@link ProtocolHandler} implementation which plays a tennis game.
14 * 
15 * @author Trustin Lee (trustin@apache.org)
16 * @version $Rev: 210062 $, $Date: 2005-07-11 12:52:38 +0900 $
17 */
18public class TennisPlayer implements ProtocolProvider
19{
20    private final ProtocolHandler HANDLER = new TennisPlayerHandler();
21    
22    public ProtocolCodecFactory getCodecFactory()
23    {
24        throw new UnsupportedOperationException();
25    }
26 
27    public ProtocolHandler getHandler()
28    {
29        return HANDLER;
30    }
31 
32    private static class TennisPlayerHandler extends ProtocolHandlerAdapter
33    {
34        private static int nextId = 0;
35 
36        /** Player ID **/
37        private final int id = nextId++;
38 
39        public void sessionOpened( ProtocolSession session )
40        {
41            System.out.println( "Player-" + id + ": READY" );
42        }
43 
44        public void sessionClosed( ProtocolSession session )
45        {
46            System.out.println( "Player-" + id + ": QUIT" );
47        }
48 
49        public void messageReceived( ProtocolSession session, Object message )
50        {
51            System.out.println( "Player-" + id + ": RCVD " + message );
52 
53            TennisBall ball = ( TennisBall ) message;
54 
55            // Stroke: TTL decreases and PING/PONG state changes.
56            ball = ball.stroke();
57 
58            if( ball.getTTL() > 0 )
59            {
60                // If the ball is still alive, pass it back to peer.
61                session.write( ball );
62            }
63            else
64            {
65                // If the ball is dead, this player loses.
66                System.out.println( "Player-" + id + ": LOSE" );
67                session.close();
68            }
69        }
70 
71        public void messageSent( ProtocolSession session, Object message )
72        {
73            System.out.println( "Player-" + id + ": SENT " + message );
74        }
75    }
76}

[all classes][org.apache.mina.examples.tennis]
EMMA 2.0.4217 (C) Vladimir Roubtsov