/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2006  by Diether Knof and Borg Enders
 *
 *   This program is free software; you can redistribute it and/or 
 *   modify it under the terms of the GNU General Public License as 
 *   published by the Free Software Foundation; either version 2 of 
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details. 
 *   You can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 *********************************************************************/

#ifdef USE_NETWORK

#ifndef CLASS_NETWORK_CONNECTION_INTERPRETER_FREEDOKO_SENDER_HEADER
#define CLASS_NETWORK_CONNECTION_INTERPRETER_FREEDOKO_SENDER_HEADER

#ifndef CLASS_NETWORK_CONNECTION_INTERPRETER_FREEDOKO_HEADER
#error Must be included from 'interpreter.h'
#endif

/**
 ** base class for an the outgoing messages
 **
 ** @author	Diether Knof
 **/
class Sender : public Connection::Interpreter::Sender {
  public:
    // constructor
    Sender(Interpreter& interpreter);
    // destructor
    ~Sender();

    // the arrival of a message was confirmated
    void confirmation(unsigned const number);

    // a message was received
    void received(unsigned const number);

    // the connection is up
    void connection_up();

    // send a ping
    void ping();
    // send a ping with a number
    void ping(unsigned const number);
    // send a pong (reply to a ping)
    void pong();
    // send a pong with a number
    void pong(unsigned const number);

    // send the chat text
    void chat(string const& text);

    // send the name
    void name();

    // send the type of the player
    void player_type(Player const& player);
    // send the name of the player
    void player_name(Player const& player);

    // send all rules
    void rules();
    // send the specific rule
    void rule(int const type);



    //
    // gameplay
    //

    // the party is started
    void party_start();
    // a new round is started in the party
    void party_start_round(unsigned const round);
    // the party is finished
    void party_finish();


  private:
    // sends the text over the connection (with a bit of manipulation)
    void send(string const& text);
    // sends the lines
    void send_lines(string const& lines);

    // sends a special command
    void send_special(string const& text);

    // prepends the time and sends the text
    Time send_with_time(string const& text);

  private:
    // counter for the sent messages
    PROT_VAR_R(unsigned, counter);
    // pending sent messages (not yet received)
    PROT_VAR_R(list<Packet>, pending);
  private: // unused
    Sender();
    Sender(Sender const&);
    Sender& operator=(Sender const&);
}; // class Network::Interpreter::FreeDoko::Sender : public Connection::Interpreter::Sender

#endif // #ifndef CLASS_NETWORK_CONNECTION_INTERPRETER_FREEDOKO_SENDER_HEADER

#endif // #ifdef USE_NETWORK
