Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/netp2/src/network/packet/FunctionCalls.h @ 2988

Last change on this file since 2988 was 2949, checked in by scheusso, 16 years ago

Network Function calls possible now (already used in Pawn::fire/doFire)

include "network/NetworkFunction.h"
register network functions like this:

registerStaticNetworkFunction( functionPointer ); this is for static (member) functions
registerMemberNetworkFunction( class, function );
this is for non-static member functions

call network functions like this:

callStaticNetworkFunction( functionPointer, clientID, arg1, … ); clientID is 0 for server
callMemberNetworkFunction( class, function, objectID, clientID, arg1, … );
objectID can be obtained by this→getObjectID() for synchronisables

arguments must be supported by MultiType !!
object must inherit from Synchronisable !!

File size: 1.1 KB
Line 
1
2#ifndef NETWORKFUNCTIONCALLS_H
3#define NETWORKFUNCTIONCALLS_H
4
5#include "../NetworkPrereqs.h"
6
7#include <string>
8#include <cstring>
9
10#include "Packet.h"
11#include <cassert>
12
13namespace orxonox {
14
15class MultiType;
16
17namespace packet {
18/**
19        @author
20*/
21
22
23class _NetworkExport FunctionCalls : public Packet
24{
25public:
26  FunctionCalls();
27  FunctionCalls( uint8_t* data, unsigned int clientID );
28  ~FunctionCalls();
29
30  inline unsigned int getSize() const
31    { assert(!this->isDataENetAllocated()); return currentSize_; }
32  bool process();
33
34  void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
35  void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
36private:
37  uint32_t nrOfCalls_;
38  unsigned int clientID_;
39  uint32_t currentSize_;
40  uint32_t currentMemBlocks_; // this saves the number of memory blocks (of size FUNCTIONCALLS_MEM_ALLOCATION) allocated
41};
42
43} //namespace packet
44} //namespace orxonox
45
46#endif
Note: See TracBrowser for help on using the repository browser.