Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2009, 4:19:43 PM (15 years ago)
Author:
scheusso
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp2/src/orxonox/objects/Test.cc

    r2948 r2949  
    3333#include "network/NetworkFunction.h"
    3434#include "Test.h"
     35#include "util/MultiType.h"
    3536
    3637namespace orxonox
     
    4344  SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
    4445  SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
     46  SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
    4547 
    4648 
     
    5153  registerStaticNetworkFunction( &Test::printV1 );
    5254  registerMemberNetworkFunction( Test, checkU1 );
     55  registerMemberNetworkFunction( Test, printBlaBla );
    5356 
    5457  Test* Test::instance_ = 0;
     
    102105  }
    103106 
     107  void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
     108  {
     109    callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
     110  }
     111 
    104112  void Test::tick(float dt)
    105113  {
     114//     std::string str1 = "blub";
     115//     //MultiType mt1(std::string("blub"));
     116//     MultiType mt1(str1);
     117//     uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
     118//     uint8_t* temp = mem;
     119//     mt1.exportData( temp );
     120//     assert( temp-mem == mt1.getNetworkSize() );
     121//     MultiType mt2;
     122//     temp = mem;
     123//     mt2.importData( temp );
     124//     assert( temp-mem == mt1.getNetworkSize() );
     125//     COUT(0) << mt2 << endl;
    106126    if(!Core::isMaster())
    107       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
    108 //       callMemberNetworkFunction( &Test::printV1, this->getObjectID(), 0);
     127      call2(0, "bal", "a", "n", "ce");
     128//       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
     129  }
     130 
     131  void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
     132  {
     133    COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
    109134  }
    110135 
Note: See TracChangeset for help on using the changeset viewer.