1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel |
|
|
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
|
|
7 | * |
5 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
9 | * option) any later version. |
… | |
… | |
20 | * <http://www.gnu.org/licenses/>. |
18 | * <http://www.gnu.org/licenses/>. |
21 | * |
19 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
21 | */ |
24 | |
22 | |
25 | /** |
23 | /* |
26 | * \file |
|
|
27 | * Socket general functions |
24 | * Socket general functions |
28 | * |
|
|
29 | * \date 2003-12-02 |
|
|
30 | * |
|
|
31 | * Mainly deals with initialization and higher level socket |
|
|
32 | * maintenance (checking for lost connections and if data has arrived.) |
|
|
33 | * The reading of data is handled in ericserver.c |
|
|
34 | */ |
25 | */ |
35 | |
26 | |
36 | #include <global.h> |
27 | #include <global.h> |
37 | #include <sproto.h> |
28 | #include <sproto.h> |
38 | #include <sys/types.h> |
29 | #include <sys/types.h> |
… | |
… | |
155 | socket_ev.set (fd, EV_READ); |
146 | socket_ev.set (fd, EV_READ); |
156 | socket_ev.prio (2); // one higher than the ticker priority |
147 | socket_ev.prio (2); // one higher than the ticker priority |
157 | socket_ev.start (); |
148 | socket_ev.start (); |
158 | |
149 | |
159 | // initialisation done, kick it! |
150 | // initialisation done, kick it! |
160 | send_packet_printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); |
151 | INVOKE_CLIENT (CONNECT, this); |
|
|
152 | |
161 | flush (); |
153 | flush (); |
162 | |
154 | |
163 | reset_stats (); |
155 | reset_stats (); |
164 | |
156 | |
165 | clients.insert (this); |
157 | clients.insert (this); |
… | |
… | |
176 | } |
168 | } |
177 | |
169 | |
178 | void |
170 | void |
179 | client::do_destroy () |
171 | client::do_destroy () |
180 | { |
172 | { |
|
|
173 | INVOKE_CLIENT (CLIENT_DESTROY, this); |
181 | attachable::do_destroy (); |
174 | attachable::do_destroy (); |
182 | |
175 | |
183 | if (pl) |
176 | if (pl) |
184 | pl->disconnect (); |
177 | pl->disconnect (); |
185 | |
178 | |
… | |
… | |
230 | |
223 | |
231 | client * |
224 | client * |
232 | client::create (int fd, const char *peername) |
225 | client::create (int fd, const char *peername) |
233 | { |
226 | { |
234 | client *ns = new client (dup (fd), peername); |
227 | client *ns = new client (dup (fd), peername); |
|
|
228 | |
235 | ns->instantiate (); // effectively a nop right now |
229 | ns->instantiate (); // effectively a nop right now |
236 | INVOKE_CLIENT (CONNECT, ns); |
230 | |
237 | return ns; |
231 | return ns; |
238 | } |
232 | } |
239 | |
233 | |