ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/include/deliantra/communicator.h
Revision: 1.1
Committed: Sun Oct 24 20:31:39 2010 UTC (15 years, 11 months ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
use EV and plain sockets instead of asio

File Contents

# User Rev Content
1 sf-pippijn 1.1 #pragma once
2    
3     #include "interface/packet_handler.h"
4     #include "data/types.h"
5    
6     #include <vector>
7    
8     #include <ev++.h>
9    
10     // Handles the low level sending and receiving commands.
11     struct communicator
12     {
13     /// Send command to the server.
14     void send (std::string const &command);
15    
16     communicator (std::string const &server, std::string const &port);
17    
18     void set_packet_handler (interface::packet_handler &handler);
19    
20     private:
21     enum response_state
22     {
23     LENGTH,
24     COMMAND
25     };
26    
27     void read_cb (ev::io &w, int revents);
28    
29     interface::packet_handler *on;
30     ev::io sock;
31    
32     size_t response_len;
33     unsigned char response[65538];
34     };