Panda3D
Loading...
Searching...
No Matches
datagramSinkNet.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file datagramSinkNet.h
10 * @author drose
11 * @date 2009-02-15
12 */
13
14#ifndef DATAGRAMSINKNET_H
15#define DATAGRAMSINKNET_H
16
17#include "pandabase.h"
18
19#include "datagramSink.h"
20#include "connectionWriter.h"
21
22/**
23 * This class accepts datagrams one-at-a-time and sends them over the net, via
24 * a TCP connection.
25 */
26class EXPCL_PANDA_NET DatagramSinkNet : public DatagramSink, public ConnectionWriter {
27PUBLISHED:
28 explicit DatagramSinkNet(ConnectionManager *manager, int num_threads);
29
30 INLINE void set_target(Connection *connection);
31 INLINE Connection *get_target() const;
32
33 // Inherited from DatagramSink
34 virtual bool put_datagram(const Datagram &data);
35 virtual bool is_error();
36 virtual void flush();
37
38private:
39 PT(Connection) _target;
40};
41
42#include "datagramSinkNet.I"
43
44#endif
ConnectionWriter(ConnectionManager *manager, int num_threads, const std::string &thread_name=std::string())
Creates a new ConnectionWriter with the indicated number of threads to handle output.
void set_target(Connection *connection)
Specifies the Connection that will receive all future Datagrams sent.
virtual void flush()
Ensures that all datagrams previously written will be visible on the stream.
DatagramSinkNet(ConnectionManager *manager, int num_threads)
Creates a new DatagramSinkNet with the indicated number of threads to handle writing.
virtual bool is_error()
Returns true if there is an error on the target connection, or if the target has never been set.
Connection * get_target() const
Returns the current target Connection, or NULL if the target has not yet been set.
virtual bool put_datagram(const Datagram &data)
Sends the given datagram to the target.
DatagramSink()
Does nothing since this is class is just the definition of an interface.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.