Changeset 5650 in orxonox.OLD for branches/network/src/subprojects/network/simple_sync.cc
- Timestamp:
- Nov 20, 2005, 3:39:38 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/subprojects/network/simple_sync.cc
r5649 r5650 1 /* 2 orxonox - the future of 3D-vertical-scrollers 3 4 Copyright (C) 2004 orx 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 ### File Specific: 12 main-programmer: Patrick Boenzli 13 co-programmer: 14 */ 15 16 17 /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module 18 For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput 19 */ 20 #define DEBUG_MODULE_NETWORK 21 22 #include "simple_sync.h" 23 24 #include "debug.h" 25 26 /** 27 * default constructor 28 */ 29 SimpleSync::SimpleSync() 30 : Synchronizeable() 31 { 32 this->outLength = 10; 33 this->inLength = 0; 34 this->outData = new byte[this->outLength]; 35 36 for( int i = 0; i < this->outLength; i++) 37 { 38 this->outData[i] = i; 39 } 40 } 41 42 /** 43 * default destructor deletes all unneded stuff 44 */ 45 SimpleSync::~SimpleSync() 46 { 47 } 48 49 /** 50 * write data to NetworkStream 51 */ 52 void SimpleSync::writeBytes(byte* data, int length) 53 { 54 /* copy the data localy */ 55 this->inLength = length; 56 for(int i = 0; i < length; i++) 57 { 58 this->inData[i] = data[i]; 59 } 60 /* and debug output */ 61 this->writeDebug(); 62 } 63 64 65 /** 66 * read data from NetworkStream 67 */ 68 int SimpleSync::readBytes(byte* data) 69 { 70 /* write the test message */ 71 data = this->outData; 72 /* debug msg */ 73 this->readDebug(); 74 /* return the length of the test */ 75 return this->outLength; 76 } 77 78 void SimpleSync::writeDebug() 79 { 80 PRINTF(0)("Write in: |"); 81 for(int i = 0; i < inLength; i++) 82 { 83 PRINT(0)(" %i ",this->inData[i]); 84 } 85 PRINT(0)("|\n"); 86 } 87 88 void SimpleSync::readDebug() 89 { 90 PRINTF(0)("Read out: |"); 91 for(int i = 0; i < outLength; i++) 92 { 93 PRINT(0)(" %i ",this->outData[i]); 94 } 95 PRINT(0)("|\n"); 96 }
Note: See TracChangeset
for help on using the changeset viewer.