MongoDB  2.7.0
message_server.h
1 // message_server.h
2 
3 /* Copyright 2009 10gen Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  abstract database server
20  async io core, worker thread system
21  */
22 
23 #pragma once
24 
25 #include "mongo/pch.h"
26 
27 namespace mongo {
28 
29  struct LastError;
30 
32  public:
33  virtual ~MessageHandler() {}
34 
38  virtual void connected( AbstractMessagingPort* p ) = 0;
39 
44  virtual void process( Message& m , AbstractMessagingPort* p , LastError * err ) = 0;
45 
49  virtual void disconnected( AbstractMessagingPort* p ) = 0;
50  };
51 
52  class MessageServer {
53  public:
54  struct Options {
55  int port; // port to bind to
56  string ipList; // addresses to bind to
57 
58  Options() : port(0), ipList("") {}
59  };
60 
61  virtual ~MessageServer() {}
62  virtual void run() = 0;
63  virtual void setAsTimeTracker() = 0;
64  virtual void setupSockets() = 0;
65  };
66 
67  // TODO use a factory here to decide between port and asio variations
68  MessageServer * createServer( const MessageServer::Options& opts , MessageHandler * handler );
69 }
virtual void process(Message &m, AbstractMessagingPort *p, LastError *err)=0
called every time a message comes in handler is responsible for responding to client ...
Definition: message_server.h:54
Definition: message_server.h:52
Definition: message_port.h:32
virtual void disconnected(AbstractMessagingPort *p)=0
called once when a socket is disconnected
virtual void connected(AbstractMessagingPort *p)=0
called once when a socket is connected
Definition: message_server.h:31
Definition: message.h:153