[5566] | 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: |
---|
[5601] | 12 | main-programmer: claudio |
---|
[5566] | 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 | |
---|
[5647] | 23 | #include "base_object.h" |
---|
| 24 | //#include "network_protocol.h" |
---|
| 25 | #include "network_socket.h" |
---|
| 26 | #include "connection_monitor.h" |
---|
| 27 | #include "synchronizeable.h" |
---|
| 28 | #include "list.h" |
---|
| 29 | |
---|
| 30 | |
---|
[5566] | 31 | /* include your own header */ |
---|
| 32 | #include "network_stream.h" |
---|
| 33 | |
---|
[5595] | 34 | /* probably unnecessary */ |
---|
[5594] | 35 | using namespace std; |
---|
| 36 | |
---|
[5595] | 37 | |
---|
[5647] | 38 | NetworkStream::NetworkStream(DataStream& inStream, DataStream& outStream) |
---|
| 39 | : DataStream(inStream, outStream) |
---|
| 40 | { |
---|
| 41 | this->init(); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | NetworkStream::NetworkStream(Synchronizeable& sync, NetworkSocket& socket) |
---|
| 45 | : DataStream(sync, socket) |
---|
| 46 | { |
---|
| 47 | this->init(); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | NetworkStream::NetworkStream(DataStream& inStream, NetworkSocket& socket) |
---|
| 51 | : DataStream(inStream, socket) |
---|
| 52 | { |
---|
| 53 | this->init(); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | NetworkStream::NetworkStream(Synchronizeable& sync, DataStream& outStream) |
---|
| 57 | : DataStream(sync, outStream) |
---|
| 58 | { |
---|
| 59 | this->init(); |
---|
| 60 | } |
---|
| 61 | |
---|
[5566] | 62 | NetworkStream::NetworkStream() |
---|
[5594] | 63 | { |
---|
[5647] | 64 | this->init(); |
---|
[5594] | 65 | /* initialize the references */ |
---|
[5647] | 66 | this->networkSocket = new NetworkSocket(); |
---|
[5610] | 67 | this->synchronizeables = new Synchronizeable(); |
---|
[5607] | 68 | this->connectionMonitor = new ConnectionMonitor(); |
---|
[5647] | 69 | } |
---|
[5607] | 70 | |
---|
[5610] | 71 | |
---|
[5647] | 72 | void NetworkStream::init() |
---|
| 73 | { |
---|
| 74 | /* set the class id for the base object */ |
---|
| 75 | this->setClassID(CL_NETWORK_STREAM, "NetworkStream"); |
---|
[5594] | 76 | } |
---|
| 77 | |
---|
[5647] | 78 | |
---|
[5566] | 79 | NetworkStream::~NetworkStream() |
---|
[5598] | 80 | { |
---|
[5608] | 81 | delete networkSockets; |
---|
| 82 | delete synchronizeables; |
---|
| 83 | delete connectionMonitor; |
---|
[5566] | 84 | |
---|
[5598] | 85 | } |
---|
| 86 | |
---|
[5604] | 87 | void NetworkStream::processData() |
---|
| 88 | { |
---|
[5610] | 89 | byte data[10] ; // obsolete, for debugging only |
---|
| 90 | byte* test = (byte *)data[0]; // obsolete, for debugging only |
---|
[5615] | 91 | int ret = 0; |
---|
[5610] | 92 | this->synchronizeables->writeByteStream(NULL); |
---|
[5615] | 93 | ret = this->networkSockets->writeBytes(NULL,1); |
---|
[5610] | 94 | test = this->synchronizeables->readByteStream(); |
---|
[5615] | 95 | ret = this->networkSockets->readBytes(test,1); |
---|
[5604] | 96 | } |
---|
[5598] | 97 | |
---|