]> Dogcows Code - chaz/yoink/blob - src/moof/service.cc
fixed documentation about where to find licenses
[chaz/yoink] / src / moof / service.cc
1
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
4 *
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
7 *
8 *****************************************************************************/
9
10 #include "service.hh"
11 #include "socket.hh"
12
13 #define SOLICIT 0x1234ABCD
14 #define RESPONSE 0xABCD1234
15
16
17 namespace moof {
18
19
20 int service::handle_packet(socket_multiplexer& mux,
21 packet& packet, const socket::address& address)
22 {
23 try
24 {
25 uint32_t magic;
26 packet >> magic;
27 if (magic == SOLICIT)
28 {
29 std::string type;
30 packet >> type;
31 if (type == type_)
32 {
33 packet.clear();
34 packet << RESPONSE << type_ << name_ << text_;
35 mux.socket().write(packet);
36 return 0;
37 }
38 }
39 }
40 catch (...)
41 {
42 }
43 return -1;
44 }
45
46 int service_finder::handle_packet(socket_multiplexer& mux,
47 packet& packet, const socket::address& address)
48 {
49 try
50 {
51 uint32_t magic;
52 packet >> magic;
53 if (magic == RESPONSE)
54 {
55 std::string type;
56 packet >> type;
57 if (type == type_)
58 {
59 std::string name;
60 std::string text;
61 packet >> name >> text;
62 service service(address, type, name, text);
63 services_.insert(std::make_pair(name, service));
64 return 0;
65 }
66 }
67 }
68 catch (...)
69 {
70 }
71 return -1;
72 }
73
74 service_finder::service_finder(const std::string& type, int sockType)
75 {
76 }
77
78
79 } // namespace moof
80
This page took 0.033178 seconds and 4 git commands to generate.