Imported more code from the old engine.
[peakengine.git] / engine / include / network / BroadcastHost.h
blob9e54c32a75f3ef3ed802bca4adfe502d76937e27
1 /*
2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #ifndef _BROADCASTHOST_H_
23 #define _BROADCASTHOST_H_
25 #include <enet/enet.h>
26 #include <string>
28 //tolua_begin
29 namespace peak
31 /**
32 * \brief Socket which automatically replies to broadcast messages.
34 class BroadcastHost
36 public:
37 BroadcastHost();
38 ~BroadcastHost();
40 /**
41 * \brief Initializes the broadcast host.
42 * \param port Port on which the socket listens
44 bool init(int port);
45 /**
46 * \brief Destroys the broadcast host.
48 bool shutdown(void);
50 /**
51 * \brief Sets the reply of the broadcast host.
52 * \param info Reply string
54 void setInfo(std::string info);
55 /**
56 * \brief Returns the used reply string.
58 std::string getInfo(void);
60 /**
61 * \brief Listens for incoming data and sends replies.
63 void doWork(void);
64 private:
65 //tolua_end
66 ENetSocket bcastsocket;
68 std::string info;
69 //tolua_begin
72 //tolua_end
74 #endif