Planeshift
clientmsghandler.h
Go to the documentation of this file.
1 /*
2  * ClientMsgHandler.h by Keith Fulton <keith@paqrat.com>
3  *
4  * Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef __CLNTMSGHANDLER_H__
20 #define __CLNTMSGHANDLER_H__
21 
22 #include <csutil/scf.h>
23 
24 #include "net/msghandler.h"
25 #include "util/genericevent.h"
26 
27 class psNetConnection;
28 class NetBase;
29 struct iObjectRegistry;
30 
39 {
40 public:
42  virtual ~ClientMsgHandler();
43 
45  bool Initialize(NetBase *nb, iObjectRegistry* object_reg);
46 
50  bool Connect(const char* server, int port);
51 
56  void SendMessage(MsgEntry* msg) { netbase->SendMessage(msg); }
57 
64  bool HandleEvent(iEvent &Event);
65 
69  bool DispatchQueue();
70 
72  int GetNextSequenceNumber(msgtype mtype);
73 
74 
76  DeclareGenericEventHandler(EventHandler,ClientMsgHandler,"planeshift.clientmsghandler");
77  csRef<EventHandler> scfiEventHandler;
78 
79 protected:
80  iObjectRegistry* object_reg;
81  csHash<OrderedMessageChannel*> orderedMessages;
82 };
83 
86 #endif
iObjectRegistry * object_reg
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
bool HandleEvent(iEvent &Event)
This function implementes the iEventHandler interface and is called whenever a subscribed event occur...
Client-side UDP handler.
Definition: connection.h:42
Handles messages to be sent out, connects to server and send those.
virtual bool SendMessage(MsgEntry *me)
Put a message into the outgoing queue.
bool Initialize(NetBase *nb, iObjectRegistry *object_reg)
Initializes the Handler.
void SendMessage(MsgEntry *msg)
Send outgoing messages, setting the clientnum automatically beforehand.
virtual ~ClientMsgHandler()
bool Connect(const char *server, int port)
This is a conveniance function that basically calls NetBase::Connect.
This class acts as a base for client/server net classes.
Definition: netbase.h:116
uint8_t msgtype
Definition: message.h:56
This class is the client&#39;s and server&#39;s main interface for either sending network messages out or get...
Definition: msghandler.h:106
int GetNextSequenceNumber(msgtype mtype)
Get the next sequence number to use for an ordered message.
NetBase * netbase
Definition: msghandler.h:187
bool DispatchQueue()
This function Publish all messages currently in the inbound message queue.
DeclareGenericEventHandler(EventHandler, ClientMsgHandler,"planeshift.clientmsghandler")
Declare our event handler.
csRef< EventHandler > scfiEventHandler
csHash< OrderedMessageChannel * > orderedMessages