Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/network_stream.cc @ 5647

Last change on this file since 5647 was 5647, checked in by patrick, 19 years ago

network: modiefied the unit test to enable diffrent modes, extended the NetworkStream constructors interface and NetworkManager interface

File size: 2.2 KB
RevLine 
[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]35using namespace std;
36
[5595]37
[5647]38NetworkStream::NetworkStream(DataStream& inStream, DataStream& outStream) 
39  : DataStream(inStream, outStream)
40{
41  this->init();
42}
43
44NetworkStream::NetworkStream(Synchronizeable& sync, NetworkSocket& socket) 
45  : DataStream(sync, socket)
46{
47  this->init();
48}
49
50NetworkStream::NetworkStream(DataStream& inStream, NetworkSocket& socket) 
51  : DataStream(inStream, socket)
52{
53  this->init();
54}
55
56NetworkStream::NetworkStream(Synchronizeable& sync, DataStream& outStream) 
57  : DataStream(sync, outStream)
58{
59  this->init();
60}
61
[5566]62NetworkStream::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]72void 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]79NetworkStream::~NetworkStream()
[5598]80{
[5608]81 delete networkSockets;
82 delete synchronizeables;
83 delete connectionMonitor;
[5566]84
[5598]85}
86
[5604]87void 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
Note: See TracBrowser for help on using the repository browser.