Loading tnl2/event_connection.h +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ protected: { public: virtual functor *create() = 0; virtual ~functor_creator() {} }; template<typename signature> class functor_creator_decl : public functor_creator Loading tnl2/net_connection.h +23 −22 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ public: { // packet stream notify stuff: bool rate_changed; ///< True if this packet requested a change of rate. time send_time; ///< getRealMilliseconds() when packet was sent. net::time send_time; ///< getRealMilliseconds() when packet was sent. uint32 sequence; packet_notify *next_packet; ///< Pointer to the next packet sent on this connection Loading Loading @@ -92,7 +92,7 @@ public: { } time _highest_acked_send_time; net::time _highest_acked_send_time; virtual void on_packet_notify(uint32 send_sequence, bool recvd) { Loading @@ -109,9 +109,9 @@ public: { _highest_acked_send_time = note->send_time; // Running average of roundTrip time if(_highest_acked_send_time != time(0)) if(_highest_acked_send_time != net::time(0)) { time round_trip_delta = _interface->get_process_start_time() - (_highest_acked_send_time + _last_received_send_delay); net::time round_trip_delta = _interface->get_process_start_time() - (_highest_acked_send_time + _last_received_send_delay); _round_trip_time = _round_trip_time * 0.9f + round_trip_delta.get_milliseconds() * 0.1f; if(_round_trip_time < 0) _round_trip_time = 0; Loading Loading @@ -163,9 +163,9 @@ public: /// Checks to see if a packet should be sent at the currentTime to the remote host. /// /// If force is true and there is space in the window, it will always send a packet. void check_packet_send(bool force, time current_time) void check_packet_send(bool force, net::time current_time) { time delay = time( _current_packet_send_period ); net::time delay = net::time( _current_packet_send_period ); if(!force) { Loading @@ -173,13 +173,13 @@ public: return; _send_delay_credit = current_time - (_last_update_time + delay - _send_delay_credit); if(_send_delay_credit > time(1000)) _send_delay_credit = time(1000); if(_send_delay_credit > net::time(1000)) _send_delay_credit = net::time(1000); } prepare_write_packet(); if(window_full() || !is_data_to_transmit()) return; packet_stream stream(_current_packet_send_size); net::packet_stream stream(_current_packet_send_size); _last_update_time = current_time; packet_notify *note = alloc_notify(); Loading @@ -197,14 +197,14 @@ public: TorqueLogMessageFormatted(LogNetConnection, ("connection %d: START", _connection) ); time send_delay = _interface->get_process_start_time() - _last_packet_recv_time; if(send_delay > time(2047)) send_delay = time(2047); net::time send_delay = _interface->get_process_start_time() - _last_packet_recv_time; if(send_delay > net::time(2047)) send_delay = net::time(2047); stream.write_integer(uint32(send_delay.get_milliseconds() >> 3), 8); write_packet(stream, note); TorqueLogMessageFormatted(LogNetConnection, ("connection %d: END - %llu bits", _connection, stream.get_bit_position() - start) ); logprintf("NC packet write data: %s", buffer_encode_base_16(stream.get_buffer(), stream.get_next_byte_position())->get_buffer()); logprintf("NC packet write data: %s", net::buffer_encode_base_16(stream.get_buffer(), stream.get_next_byte_position())->get_buffer()); torque_socket_send_to_connection(_interface->get_socket(), _connection, stream.get_next_byte_position(), stream.get_buffer(), &_last_send_sequence); //torque_connection_send_to(_connection, stream.get_next_byte_position(), stream.get_buffer(), &_last_send_sequence); Loading @@ -214,9 +214,9 @@ public: virtual void on_packet(uint32 sequence, bit_stream &data) { read_packet_rate_info(data); _last_received_send_delay = time((data.read_integer(8) << 3) + 4); _last_received_send_delay = net::time((data.read_integer(8) << 3) + 4); _last_packet_recv_time = _interface->get_process_start_time(); logprintf("NC packet read data: %s", buffer_encode_base_16(data.get_buffer(), data.get_next_byte_position())->get_buffer()); logprintf("NC packet read data: %s", net::buffer_encode_base_16(data.get_buffer(), data.get_next_byte_position())->get_buffer()); read_packet(data); } Loading Loading @@ -296,8 +296,8 @@ public: _current_packet_send_size = uint32(max_bandwidth * _current_packet_send_period * 0.001f); // make sure we don't try to overwrite the maximum packet size if(_current_packet_send_size > udp_socket::max_datagram_size) _current_packet_send_size = udp_socket::max_datagram_size; if(_current_packet_send_size > net::udp_socket::max_datagram_size) _current_packet_send_size = net::udp_socket::max_datagram_size; } /// Returns the notify structure for the current packet write, or last written packet. Loading Loading @@ -345,6 +345,7 @@ public: _local_rate_changed = true; compute_negotiated_rate(); _last_send_sequence = 0; _state = state_start; } void set_interface(net_interface *interface) Loading Loading @@ -384,11 +385,11 @@ protected: packet_notify *_notify_queue_tail; ///< Tail of the notify queue linked list. New packets are added to the end of the tail. torque_connection_id _connection; time _last_packet_recv_time; ///< time of the receipt of the last data packet. net::time _last_packet_recv_time; ///< time of the receipt of the last data packet. float32 _round_trip_time; ///< Running average round trip time. time _send_delay_credit; ///< Metric to help compensate for irregularities on fixed rate packet sends. time _last_update_time; net::time _send_delay_credit; ///< Metric to help compensate for irregularities on fixed rate packet sends. net::time _last_update_time; safe_ptr<net_interface> _interface; uint32 _last_send_sequence; time _last_received_send_delay; net::time _last_received_send_delay; }; tnl2/net_interface.h +7 −7 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ class net_interface : public ref_object }; public: void set_private_key(asymmetric_key_ptr the_key) void set_private_key(net::asymmetric_key_ptr the_key) { byte_buffer_ptr key_buffer = the_key->get_private_key(); torque_socket_set_private_key(_socket, key_buffer->get_buffer_size(), key_buffer->get_buffer()); Loading Loading @@ -151,13 +151,13 @@ public: obj->_prev_dirty_list = &_dirty_list_head; } time get_process_start_time() net::time get_process_start_time() { return _process_start_time; } void check_for_packet_sends() { _process_start_time = time::get_current(); _process_start_time = net::time::get_current(); collapse_dirty_list(); for(uint32 i = 0; i < _connection_table.size(); i++) { Loading Loading @@ -223,7 +223,7 @@ public: void _process_connection_accepted(torque_socket_event *event) { packet_stream response_stream; net::packet_stream response_stream; connection_pointer p = _connection_table.find(event->connection); Loading Loading @@ -307,7 +307,7 @@ public: } void connect(const address &remote_host, ref_ptr<net_connection> &the_connection) void connect(const net::address &remote_host, ref_ptr<net_connection> &the_connection) { uint8 connect_buffer[torque_sockets_max_status_datagram_size]; bit_stream connect_stream(connect_buffer, sizeof(connect_buffer)); Loading Loading @@ -336,7 +336,7 @@ public: return _socket; } net_interface(const address &bind_address) net_interface(const net::address &bind_address) { sockaddr sa_bind_address; bind_address.to_sockaddr(&sa_bind_address); Loading @@ -349,7 +349,7 @@ public: } protected: torque_socket_handle _socket; time _process_start_time; net::time _process_start_time; net_object _dirty_list_head; net_object _dirty_list_tail; array<connection_type_record> _connection_class_table; Loading tnl2_test/Makefile +1 −1 Original line number Diff line number Diff line ############################################################################# # Makefile for building: tnl2_test.app/Contents/MacOS/tnl2_test # Generated by qmake (2.01a) (Qt 4.6.2) on: Thu Mar 18 18:20:20 2010 # Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Mar 19 06:57:39 2010 # Project: tnl2_test.pro # Template: app # Command: /usr/bin/qmake -spec /usr/local/Qt4.6/mkspecs/macx-g++ -macx -o Makefile tnl2_test.pro Loading tnl2_test/test_building.h +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ public: position lower_right; ///< Lower right corner of the building rectangle on the screen. /// The building constructor creates a random position and extent for the building, and marks it as scopeAlways. building(random_generator *random_gen = 0) building(net::random_generator *random_gen = 0) { // place the "building" in a random position on the screen if(random_gen) Loading Loading
tnl2/event_connection.h +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ protected: { public: virtual functor *create() = 0; virtual ~functor_creator() {} }; template<typename signature> class functor_creator_decl : public functor_creator Loading
tnl2/net_connection.h +23 −22 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ public: { // packet stream notify stuff: bool rate_changed; ///< True if this packet requested a change of rate. time send_time; ///< getRealMilliseconds() when packet was sent. net::time send_time; ///< getRealMilliseconds() when packet was sent. uint32 sequence; packet_notify *next_packet; ///< Pointer to the next packet sent on this connection Loading Loading @@ -92,7 +92,7 @@ public: { } time _highest_acked_send_time; net::time _highest_acked_send_time; virtual void on_packet_notify(uint32 send_sequence, bool recvd) { Loading @@ -109,9 +109,9 @@ public: { _highest_acked_send_time = note->send_time; // Running average of roundTrip time if(_highest_acked_send_time != time(0)) if(_highest_acked_send_time != net::time(0)) { time round_trip_delta = _interface->get_process_start_time() - (_highest_acked_send_time + _last_received_send_delay); net::time round_trip_delta = _interface->get_process_start_time() - (_highest_acked_send_time + _last_received_send_delay); _round_trip_time = _round_trip_time * 0.9f + round_trip_delta.get_milliseconds() * 0.1f; if(_round_trip_time < 0) _round_trip_time = 0; Loading Loading @@ -163,9 +163,9 @@ public: /// Checks to see if a packet should be sent at the currentTime to the remote host. /// /// If force is true and there is space in the window, it will always send a packet. void check_packet_send(bool force, time current_time) void check_packet_send(bool force, net::time current_time) { time delay = time( _current_packet_send_period ); net::time delay = net::time( _current_packet_send_period ); if(!force) { Loading @@ -173,13 +173,13 @@ public: return; _send_delay_credit = current_time - (_last_update_time + delay - _send_delay_credit); if(_send_delay_credit > time(1000)) _send_delay_credit = time(1000); if(_send_delay_credit > net::time(1000)) _send_delay_credit = net::time(1000); } prepare_write_packet(); if(window_full() || !is_data_to_transmit()) return; packet_stream stream(_current_packet_send_size); net::packet_stream stream(_current_packet_send_size); _last_update_time = current_time; packet_notify *note = alloc_notify(); Loading @@ -197,14 +197,14 @@ public: TorqueLogMessageFormatted(LogNetConnection, ("connection %d: START", _connection) ); time send_delay = _interface->get_process_start_time() - _last_packet_recv_time; if(send_delay > time(2047)) send_delay = time(2047); net::time send_delay = _interface->get_process_start_time() - _last_packet_recv_time; if(send_delay > net::time(2047)) send_delay = net::time(2047); stream.write_integer(uint32(send_delay.get_milliseconds() >> 3), 8); write_packet(stream, note); TorqueLogMessageFormatted(LogNetConnection, ("connection %d: END - %llu bits", _connection, stream.get_bit_position() - start) ); logprintf("NC packet write data: %s", buffer_encode_base_16(stream.get_buffer(), stream.get_next_byte_position())->get_buffer()); logprintf("NC packet write data: %s", net::buffer_encode_base_16(stream.get_buffer(), stream.get_next_byte_position())->get_buffer()); torque_socket_send_to_connection(_interface->get_socket(), _connection, stream.get_next_byte_position(), stream.get_buffer(), &_last_send_sequence); //torque_connection_send_to(_connection, stream.get_next_byte_position(), stream.get_buffer(), &_last_send_sequence); Loading @@ -214,9 +214,9 @@ public: virtual void on_packet(uint32 sequence, bit_stream &data) { read_packet_rate_info(data); _last_received_send_delay = time((data.read_integer(8) << 3) + 4); _last_received_send_delay = net::time((data.read_integer(8) << 3) + 4); _last_packet_recv_time = _interface->get_process_start_time(); logprintf("NC packet read data: %s", buffer_encode_base_16(data.get_buffer(), data.get_next_byte_position())->get_buffer()); logprintf("NC packet read data: %s", net::buffer_encode_base_16(data.get_buffer(), data.get_next_byte_position())->get_buffer()); read_packet(data); } Loading Loading @@ -296,8 +296,8 @@ public: _current_packet_send_size = uint32(max_bandwidth * _current_packet_send_period * 0.001f); // make sure we don't try to overwrite the maximum packet size if(_current_packet_send_size > udp_socket::max_datagram_size) _current_packet_send_size = udp_socket::max_datagram_size; if(_current_packet_send_size > net::udp_socket::max_datagram_size) _current_packet_send_size = net::udp_socket::max_datagram_size; } /// Returns the notify structure for the current packet write, or last written packet. Loading Loading @@ -345,6 +345,7 @@ public: _local_rate_changed = true; compute_negotiated_rate(); _last_send_sequence = 0; _state = state_start; } void set_interface(net_interface *interface) Loading Loading @@ -384,11 +385,11 @@ protected: packet_notify *_notify_queue_tail; ///< Tail of the notify queue linked list. New packets are added to the end of the tail. torque_connection_id _connection; time _last_packet_recv_time; ///< time of the receipt of the last data packet. net::time _last_packet_recv_time; ///< time of the receipt of the last data packet. float32 _round_trip_time; ///< Running average round trip time. time _send_delay_credit; ///< Metric to help compensate for irregularities on fixed rate packet sends. time _last_update_time; net::time _send_delay_credit; ///< Metric to help compensate for irregularities on fixed rate packet sends. net::time _last_update_time; safe_ptr<net_interface> _interface; uint32 _last_send_sequence; time _last_received_send_delay; net::time _last_received_send_delay; };
tnl2/net_interface.h +7 −7 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ class net_interface : public ref_object }; public: void set_private_key(asymmetric_key_ptr the_key) void set_private_key(net::asymmetric_key_ptr the_key) { byte_buffer_ptr key_buffer = the_key->get_private_key(); torque_socket_set_private_key(_socket, key_buffer->get_buffer_size(), key_buffer->get_buffer()); Loading Loading @@ -151,13 +151,13 @@ public: obj->_prev_dirty_list = &_dirty_list_head; } time get_process_start_time() net::time get_process_start_time() { return _process_start_time; } void check_for_packet_sends() { _process_start_time = time::get_current(); _process_start_time = net::time::get_current(); collapse_dirty_list(); for(uint32 i = 0; i < _connection_table.size(); i++) { Loading Loading @@ -223,7 +223,7 @@ public: void _process_connection_accepted(torque_socket_event *event) { packet_stream response_stream; net::packet_stream response_stream; connection_pointer p = _connection_table.find(event->connection); Loading Loading @@ -307,7 +307,7 @@ public: } void connect(const address &remote_host, ref_ptr<net_connection> &the_connection) void connect(const net::address &remote_host, ref_ptr<net_connection> &the_connection) { uint8 connect_buffer[torque_sockets_max_status_datagram_size]; bit_stream connect_stream(connect_buffer, sizeof(connect_buffer)); Loading Loading @@ -336,7 +336,7 @@ public: return _socket; } net_interface(const address &bind_address) net_interface(const net::address &bind_address) { sockaddr sa_bind_address; bind_address.to_sockaddr(&sa_bind_address); Loading @@ -349,7 +349,7 @@ public: } protected: torque_socket_handle _socket; time _process_start_time; net::time _process_start_time; net_object _dirty_list_head; net_object _dirty_list_tail; array<connection_type_record> _connection_class_table; Loading
tnl2_test/Makefile +1 −1 Original line number Diff line number Diff line ############################################################################# # Makefile for building: tnl2_test.app/Contents/MacOS/tnl2_test # Generated by qmake (2.01a) (Qt 4.6.2) on: Thu Mar 18 18:20:20 2010 # Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Mar 19 06:57:39 2010 # Project: tnl2_test.pro # Template: app # Command: /usr/bin/qmake -spec /usr/local/Qt4.6/mkspecs/macx-g++ -macx -o Makefile tnl2_test.pro Loading
tnl2_test/test_building.h +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ public: position lower_right; ///< Lower right corner of the building rectangle on the screen. /// The building constructor creates a random position and extent for the building, and marks it as scopeAlways. building(random_generator *random_gen = 0) building(net::random_generator *random_gen = 0) { // place the "building" in a random position on the screen if(random_gen) Loading