| [5829] | 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 "read_sync.h" | 
|---|
|  | 23 |  | 
|---|
|  | 24 | #include "debug.h" | 
|---|
|  | 25 |  | 
|---|
|  | 26 |  | 
|---|
|  | 27 | /** | 
|---|
|  | 28 | *  default constructor | 
|---|
|  | 29 | */ | 
|---|
|  | 30 | ReadSync::ReadSync(const char* name) | 
|---|
| [6634] | 31 | : Synchronizeable() | 
|---|
| [5829] | 32 | { | 
|---|
|  | 33 | /* define the local buffer size */ | 
|---|
|  | 34 |  | 
|---|
|  | 35 | this->inLength = 100; | 
|---|
|  | 36 | this->recLength = 0; | 
|---|
|  | 37 | this->inData = new byte[this->inLength]; | 
|---|
|  | 38 |  | 
|---|
|  | 39 | /* init the buffer data */ | 
|---|
|  | 40 | for( int i = 0; i < this->inLength; i++) | 
|---|
|  | 41 | { | 
|---|
|  | 42 | this->inData[i] = 0; | 
|---|
|  | 43 | } | 
|---|
|  | 44 |  | 
|---|
|  | 45 | } | 
|---|
|  | 46 |  | 
|---|
|  | 47 |  | 
|---|
|  | 48 | /** | 
|---|
|  | 49 | *  default destructor deletes all unneded stuff | 
|---|
|  | 50 | */ | 
|---|
|  | 51 | ReadSync::~ReadSync() | 
|---|
|  | 52 | { | 
|---|
|  | 53 |  | 
|---|
|  | 54 | if( this->inData) | 
|---|
|  | 55 | delete[] this->inData; | 
|---|
|  | 56 | } | 
|---|
|  | 57 |  | 
|---|
|  | 58 |  | 
|---|
|  | 59 | /** | 
|---|
|  | 60 | *  write data to Synchronizeable | 
|---|
|  | 61 | */ | 
|---|
| [6341] | 62 | int ReadSync::writeBytes(const byte* data, int length, int sender) | 
|---|
| [5829] | 63 | { | 
|---|
|  | 64 | PRINTF(0)("ReadSync: got %i bytes of data\n", length); | 
|---|
|  | 65 | this->recLength = length; | 
|---|
|  | 66 | if(this->inLength < length) | 
|---|
|  | 67 | PRINTF(0)("ERROR: local buffer is smaller than the data to receive.\n"); | 
|---|
|  | 68 |  | 
|---|
|  | 69 | /* copy the data localy */ | 
|---|
|  | 70 | for( int i = 0; i < length; i++) | 
|---|
|  | 71 | { | 
|---|
|  | 72 | this->inData[i] = data[i]; | 
|---|
|  | 73 | } | 
|---|
|  | 74 | /* and debug output */ | 
|---|
|  | 75 | this->writeDebug(); | 
|---|
|  | 76 | } | 
|---|
|  | 77 |  | 
|---|
|  | 78 |  | 
|---|
|  | 79 | /** | 
|---|
|  | 80 | *  read data from Synchronizeable | 
|---|
|  | 81 | */ | 
|---|
| [6139] | 82 | int ReadSync::readBytes(byte* data, int maxLength, int * reciever) | 
|---|
| [5829] | 83 | { | 
|---|
|  | 84 | return 0; | 
|---|
|  | 85 | } | 
|---|
|  | 86 |  | 
|---|
|  | 87 |  | 
|---|
|  | 88 | void ReadSync::writeDebug() const | 
|---|
|  | 89 | { | 
|---|
|  | 90 | PRINTF(0)("Write in bytes: \t(0 <-) |"); | 
|---|
|  | 91 | for(int i = 0; i < this->recLength; i++) | 
|---|
|  | 92 | { | 
|---|
|  | 93 | PRINT(0)(" [%u] ",this->inData[i]); | 
|---|
|  | 94 | } | 
|---|
|  | 95 | PRINT(0)("|\n"); | 
|---|
|  | 96 | } | 
|---|
|  | 97 |  | 
|---|
|  | 98 |  | 
|---|
|  | 99 | void ReadSync::readDebug() const | 
|---|
|  | 100 | {} | 
|---|