summaryrefslogtreecommitdiff
path: root/src/syncServer.h
blob: ed0d4fddf571bfe7d1cc5833f5207f79ede1cb13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef _SYNC_SERVER_H_
#define _SYNC_SERVER_H_
//#include <iostream>
//#include <string>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/function.hpp>
#include "threadUtils.hpp"


#include <boost/asio.hpp>
#include <list>
#include "syncTcpConnection.h"

//using boost::asio::ip::tcp;

class SyncServer
{
public:
  SyncServer(boost::asio::io_service& io_service,  boost::asio::ip::tcp::endpoint tcp_endpoint );
	boost::function<void(SyncTcpConnection *)> onConnect;
  std::list<SyncTcpConnection::pointer> conns_;
	void send(std::string message);
private:
  void start_accept();
  void handle_accept(SyncTcpConnection::pointer new_connection,
      const boost::system::error_code& error);
	Mutex mutex_; //Mutex for list conns_
  boost::asio::ip::tcp::acceptor acceptor_;
};
#endif