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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#ifndef CONNECTION_H__
#define CONNECTION_H__
#define RAW 0 // These two are in place for send_to_socket
#define COOKED 1
#include "sysdep.h"
#include "strings.h"
#include "mudtypes.h"
#include "linkedlist.h"
class MudObject;
class Connection;
struct snoop_struct {
Connection *user;
snoop_struct *next_snoop;
};
#define SNOOP_SPECTATE 0
class Connection {
public:
int check_socket();
int send_to_socket(char *the_string, int cook_mode);
int send_to_socket(char *the_string);
int send_to_socket(Strings *the_string, int cook_mode);
int send_to_socket(Strings *the_string);
time_t lost_link();
bool has_input();
bool has_output();
Strings *get_input();
void flush();
int find_host_addr();
char *get_ip_addr();
char *get_host_addr();
int echo_off();
int echo_on();
int get_socknum();
void set_color(int the_val);
time_t get_idle(void);
Strings *get_pager_buffer();
void start_paging();
int end_paging(MudObject *the_user);
int set_owner(MudObject *sock_own);
int add_snoop(Connection *the_conn);
int remove_snoop(Connection *the_conn);
int has_snoop(Connection *the_conn);
int remove_all_snoop(int snoop_type);
int send_to_snoopers(char *the_output);
int send_to_snoopers(char *the_output, int is_input);
void set_valid();
Connection();
Connection(int the_socket, MudObject *sock_own);
~Connection();
protected:
int fill_read_buffer(char *input_buf);
private:
int write_to_buffer(char *the_string);
fd_set read_fds;
fd_set write_fds;
fd_set except_fds;
struct sockaddr_in sin;
int socketfd;
bool valid_socket;
bool valid_input;
bool hold_buffers;
Strings pager_buffer;
Strings write_buffer;
LinkedList<Strings> read_buffer;
Strings partial_line;
Strings ip_addr;
Strings host_addr;
int use_color;
MudObject *owner; // Player/Builder this connection is attached to
snoop_struct *snoop_list; /* who is listening in to our output */
time_t lost_connection; /* when this person lost link */
time_t last_input; /* when the last full input was */
};
#endif
|