Atlas 0.7.0
Networking protocol for the Worldforge system.
Stream.h
1// This file may be redistributed and modified only under the terms of
2// the GNU Lesser General Public License (See COPYING for details).
3// Copyright (C) 2000-2001 Michael Day, Dmitry Derevyanko, Stefanus Du Toit
4
5// $Id$
6
7#ifndef ATLAS_NET_STREAM_H
8#define ATLAS_NET_STREAM_H
9
10#include <Atlas/Negotiate.h>
11
12#include <iosfwd>
13#include <string>
14#include <list>
15
16namespace Atlas {
17
18class Bridge;
19
23namespace Net {
24
37
38 public:
39
40 explicit NegotiateHelper(std::list<std::string> & names);
41
42 bool get(std::string &buf, const std::string & header);
43 void put(std::string &buf, const std::string & header);
44
45 private:
46
47 std::list<std::string> & m_names;
48
49 };
50
59{
60 public:
61
62 StreamConnect(std::string name, std::istream& inStream, std::ostream& outStream);
63
64 ~StreamConnect() override = default;
65
66 void poll() override;
67
68 State getState() override;
69
70 std::unique_ptr<Atlas::Codec> getCodec(Atlas::Bridge&) override;
71
72 private:
73
74 enum
75 {
76 SERVER_GREETING,
77 CLIENT_GREETING,
78 CLIENT_CODECS,
79 SERVER_CODECS,
80 // CLIENT_FILTERS,
81 // SERVER_FILTERS,
82 DONE
83 };
84
85 int m_state;
86
87 std::string m_outName;
88 std::string m_inName;
89 std::istream& m_inStream;
90 std::ostream& m_outStream;
91 std::list<std::string> m_inCodecs;
92 std::list<std::string> m_inFilters;
93
94 NegotiateHelper m_codecHelper;
95 NegotiateHelper m_filterHelper;
96 std::string m_buf;
97
98 void processServerCodecs();
99 void processServerFilters();
100
101 //void processClientCodecs();
102 //void processClientFilters();
103
104 bool m_canPacked;
105 bool m_canXML;
106 bool m_canBach;
107
108 bool m_canGzip;
109 bool m_canBzip2;
110};
111
121{
122 public:
123
124 StreamAccept(std::string name, std::istream& inStream, std::ostream& outStream);
125
126 ~StreamAccept() override = default;
127
128 void poll() override;
129
130 State getState() override;
131
132 std::unique_ptr<Atlas::Codec> getCodec(Atlas::Bridge&) override;
133
134 private:
135
136 enum
137 {
138 SERVER_GREETING,
139 CLIENT_GREETING,
140 CLIENT_CODECS,
141 SERVER_CODECS,
142 CLIENT_FILTERS,
143 SERVER_FILTERS,
144 DONE
145 };
146
147 int m_state;
148
149 std::string m_outName;
150 std::string m_inName;
151 std::istream& m_inStream;
152 std::ostream& m_outStream;
153 std::list<std::string> m_inCodecs;
154 std::list<std::string> m_inFilters;
155
156 NegotiateHelper m_codecHelper;
157 NegotiateHelper m_filterHelper;
158 std::string m_buf;
159
160 //void processServerCodecs();
161 //void processServerFilters();
162
163 void processClientCodecs();
164 void processClientFilters();
165
166 bool m_canPacked;
167 bool m_canXML;
168 bool m_canBach;
169
170 bool m_canGzip;
171 bool m_canBzip2;
172};
173
174} } // namespace Atlas::Net
175
176#endif
177
std::unique_ptr< Atlas::Codec > getCodec(Atlas::Bridge &) override
FIXME We should pass in the Bridge here, not at construction time.
Definition: Stream.cpp:345
std::unique_ptr< Atlas::Codec > getCodec(Atlas::Bridge &) override
FIXME We should pass in the Bridge here, not at construction time.
Definition: Stream.cpp:190
Definition: Bridge.h:20