| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file network.h |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created OpenJazz.h |
| 10 | * - 3rd June 2009: Created network.h from parts of OpenJazz.h |
| 11 | * |
| 12 | * @par Licence: |
| 13 | * Copyright (c) 2005-2017 AJ Thomson |
| 14 | * |
| 15 | * OpenJazz is distributed under the terms of |
| 16 | * the GNU General Public License, version 2.0 |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #ifndef _NETWORK_H |
| 21 | #define _NETWORK_Hcxx . . $ `src/io/network.h:21:9`! |
| 22 | |
| 23 | |
| 24 | #include "OpenJazz.h"cxx . . $ `<file>/src/OpenJazz.h`/ |
| 25 | |
| 26 | #ifdef USE_SDL_NET |
| 27 | #include <SDL_net.h> |
| 28 | #endif |
| 29 | |
| 30 | // Constants |
| 31 | |
| 32 | // Defaults |
| 33 | #if defined(DINGOO) |
| 34 | #define NET_ADDRESS "10.1.0.1" |
| 35 | #else |
| 36 | #define NET_ADDRESScxx . . $ `src/io/network.h:36:10`! "192.168.0.1" |
| 37 | #endif |
| 38 | #define NET_PORTcxx . . $ `src/io/network.h:38:9`! 10052 |
| 39 | |
| 40 | // Timeout interval |
| 41 | #define T_TIMEOUTcxx . . $ `src/io/network.h:41:9`! 30000 |
| 42 | |
| 43 | // Client limit |
| 44 | #define MAX_CLIENTScxx . . $ `src/io/network.h:44:9`! 31 |
| 45 | |
| 46 | // Level file |
| 47 | #define LEVEL_FILEcxx . . $ `src/io/network.h:47:9`! "openjazz.tmp" |
| 48 | |
| 49 | |
| 50 | // Class |
| 51 | |
| 52 | /// Networking |
| 53 | class Networkcxx . . $ Network# { |
| 54 | |
| 55 | public: |
| 56 | #ifdef USE_SDL_NET |
| 57 | TCPsocket socket; |
| 58 | TCPsocket clientSocket; |
| 59 | IPaddress ipAddress; |
| 60 | SDLNet_SocketSet socketset; |
| 61 | #endif |
| 62 | |
| 63 | Networkcxx . . $ Network#Network(49f6e7a06ebc5aa8). (); |
| 64 | ~cxx . . $ Network#`~Network`(49f6e7a06ebc5aa8).Networkcxx . . $ Network# (); |
| 65 | |
| 66 | int hostcxx . . $ Network#host(b126dc7c1de90089). (); |
| 67 | int joincxx . . $ Network#join(1ef8e6ec083aabb9). (char *address); |
| 68 | int acceptcxx . . $ Network#accept(7864480464b09eea). (int sock); |
| 69 | void closecxx . . $ Network#close(d4f767463ce0a6b3). (int sock); |
| 70 | int sendcxx . . $ Network#send(b2cc8657ba51080d). (int sock, unsigned char *buffer); |
| 71 | int recvcxx . . $ Network#recv(ef9024b465536c23). (int sock, unsigned char *buffer, int length); |
| 72 | bool isConnectedcxx . . $ Network#isConnected(83c267b20bac841a). (int sock); |
| 73 | int getErrorcxx . . $ Network#getError(b126dc7c1de90089). (); |
| 74 | |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | // Variables |
| 79 | |
| 80 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! char *netAddresscxx . . $ netAddress.; /// Server address |
| 81 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Networkcxx . . $ Network# *netcxx . . $ net.; |
| 82 | |
| 83 | #endif |
| 84 |