remote_client.hpp 1.81 KB
Newer Older
1 2 3 4 5
/** @addtogroup Network
 *  @{
 */

/**
6 7
 * Represents one single remote client connected to the main server (the one
 * doing authentication, history, chat, etc).
8 9 10
 * @class RemoteClient
 */

louiz’'s avatar
louiz’ committed
11 12
#ifndef __REMOTE_CLIENT_HPP__
# define __REMOTE_CLIENT_HPP__
louiz’'s avatar
louiz’ committed
13

14 15 16
#include <boost/asio.hpp>
#include <functional>

17
#include <network/remote_client_base.hpp>
18
#include <network/transfer_sender.hpp>
19
#include <network/server.hpp>
20

21
class RemoteClient: public RemoteClientBase
louiz’'s avatar
louiz’ committed
22 23
{
public:
24
  explicit RemoteClient(boost::asio::io_service&, Server<RemoteClient>*);
louiz’'s avatar
louiz’ committed
25
  ~RemoteClient();
26
  virtual void on_connection_closed();
27 28 29 30 31 32

  /**
   * Sends a file to the remote client.
   * @param filename The file to send.
   */
  void send_file(const std::string&);
33 34 35 36 37 38 39
  /**
   * Sends a ping request to the remote client.
   */
  void send_ping();
  /**
   * Called when we receive the response to our ping.
   */
40
  void on_pong(Message*);
41 42 43 44 45
  /**
   * To be called whenever a file transfer ends.
   * Removes the TransferSender from the list.
   * @param transfer The TransferSender to remove from the list.
   */
louiz’'s avatar
louiz’ committed
46
  void on_transfer_ended(const TransferSender*);
47 48 49 50 51 52
  /**
   * Called when the client is successfully authenticated.
   * For example, checks if there are news to send, or offline messages, etc
   */
  void on_auth_success();

louiz’'s avatar
louiz’ committed
53
private:
54
  /**
55 56 57
   * Creates the default callbacks associated with a network message.
   * It is executed whenever that message is received.
   * See MessageHandler for details
58
   */
59
  virtual void install_callbacks();
60 61
  void auth_callback(Message*);
  void transfer_callback(Message*);
62 63 64 65
  /**
   * A pointer to the server, to call its method when the RemoteClient
   * has to be deleted.
   */
66
  Server<RemoteClient>* server;
67
  /**
68
   * A list of all the current file transfers with the client.
69 70
   */
  std::vector<TransferSender*> senders;
louiz’'s avatar
louiz’ committed
71 72 73
};

#endif
74
/**@}*/