--- deliantra/server/include/client.h 2010/10/16 22:51:51 1.101
+++ deliantra/server/include/client.h 2012/11/09 00:11:49 1.110
@@ -1,22 +1,22 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
- *
- * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
- *
+ *
+ * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ *
* Deliantra is free software: you can redistribute it and/or modify it under
* the terms of the Affero GNU General Public License as published by the
* Free Software Foundation, either version 3 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 should have received a copy of the Affero GNU General Public License
* and the GNU General Public License along with this program. If not, see
* .
- *
+ *
* The authors can be reached via e-mail to
*/
@@ -91,12 +91,6 @@
char *range, *title;
};
-/* This contains basic information on the socket structure. status is its
- * current state. we set up our on buffers for sending/receiving, so we can
- * handle some higher level functions. fd is the actual file descriptor we
- * are using.
- */
-
// states the socket can be in
enum {
ST_DEAD, // socket is dead
@@ -115,7 +109,7 @@
PF_COMMAND6 = 0x08, // command starts at offset 6
};
-// face type.s bit 0 means "has meta info prepended"
+// face types. bit 0 means "has meta info prepended"
enum {
FT_FACE = 0 * 2 + 0, // faces (images)
FT_MUSIC = 1 * 2 + 1, // background music
@@ -144,6 +138,11 @@
/* how many times we are allowed to give the wrong password before being kicked. */
#define MAX_PASSWORD_FAILURES 5
+/* This contains basic information on the socket connection. status is its
+ * current state. we set up our on buffers for sending/receiving, so we can
+ * handle some higher level functions. fd is the actual file descriptor we
+ * are using.
+ */
INTERFACE_CLASS (client) // should become player when newsocket is a baseclass of player
struct client : zero_initialised, attachable
{
@@ -191,6 +190,7 @@
uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */
uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */
uint8 ACC (RW, faceset); // CF+ selected faceset
+ uint8 ACC (RW, ws_version); // websocket protocol versio for framing
maptile_ptr ACC (RW, current_map); // CF+ last/current player map
region_ptr ACC (RW, current_region); // CF+ last/current player region
@@ -207,21 +207,31 @@
struct tcp_info tcpi;
tstamp next_rate_adjust;
+ // websocket frame buffer
+ uint8 ws_inbuf_type; // current frame type
+ uint8 *ws_inbuf;
+ uint32 ws_inbuf_len;
+ uint32 ws_inbuf_alloc;
+
unordered_vector mapinfo_queue;
void mapinfo_queue_clear ();
void mapinfo_queue_run ();
bool mapinfo_try (char *buf);
struct ixsend {
- int16_t pri; // unused
+ int16_t pri; // higher means faces are sent earlier, default 0
faceidx idx;
uint32_t ofs; // if != 0, need to send remaining bytes of partial_face
+ refcnt_buf data;
};
std::vector > ixface; // which faces to send to the client using ix
std::vector > fxface; // which faces to send using fx
MTH void flush_fx (); // send fx if required
+ MTH void invalidate_face (faceidx idx);
+ MTH void invalidate_all_faces ();
+
void do_destroy ();
void gather_callbacks (AV *&callbacks, event_type event) const;
@@ -238,6 +248,7 @@
// if we get an incomplete packet, this is used to hold the data.
// we add 2 byte for the header, one for the trailing 0 byte
uint8 inbuf[MAXSOCKBUF + 2 + 1];
+ void inbuf_handle ();
enum { MSG_BUF_SIZE = 80, MSG_BUF_COUNT = 10 };
struct msg_buf
@@ -278,8 +289,9 @@
MTH void flush ();
MTH void write_outputbuffer ();
MTH int outputbuffer_len () const { return outputbuffer.len; }
- void send (void *buf_, int len);
+ void send_raw (void *buf_, int len);
+ void send (void *buf_, int len);
void send_packet (const_octet_string buf);
void send_packet (const_octet_string buf, int len);
void send_packet_printf (const_utf8_string format, ...) attribute ((format (printf, 2, 3)));
@@ -304,6 +316,8 @@
MTH static void clock ();
MTH static void flush_sockets ();
+ MTH void run (); // start handshake after init
+
protected:
client (int fd, const char *from_ip);
~client ();
@@ -341,18 +355,6 @@
ACC (RW, tcpi.tcpi_reordering);
#endif
-//+GPL
-
-#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\
- ( ((__type)>0) &&\
- ((__sockPtr)->has_readable_type) && \
- ((__sockPtr)->supported_readables & (1<<(__type))) )
-
-#define FACE_TYPES 1
-#define PNG_FACE_INDEX 0
-
-//-GPL
-
typedef object_vector sockvec;
extern sockvec clients;