#include <cluster/Packets/ConnectionAck.h>
Inheritance diagram for cluster::ConnectionAck:


Public Member Functions | |
| ConnectionAck () | |
| ConnectionAck (std::string host_name, vpr::Uint16 port, bool ack) | |
| Create a ConnectionAck packet to acknowledge a ConnectionRequest. | |
| void | serialize () |
| Serializes member variables into a data stream. | |
| virtual void | parse (vpr::BufferObjectReader *reader) |
| Parses the data stream into the local member variables. | |
| virtual void | printData (int debug_level) |
| Print the data to the screen in a readable form. | |
| std::string | getHostname () |
| Return the hostname of the machine that is acknowledging the connection. | |
| vpr::Uint16 | getPort () |
| Return the port that the acknowledging machine is listening on. | |
| bool | getAck () |
| Return a boolean determining if this is a positive(ACK) or a negative(NACK) responce. | |
Static Public Member Functions | |
| static vpr::Uint16 | getPacketFactoryType () |
| Return the type of this packet. | |
Definition at line 52 of file ConnectionAck.h.
| cluster::ConnectionAck::ConnectionAck | ( | ) | [inline] |
| cluster::ConnectionAck::ConnectionAck | ( | std::string | host_name, | |
| vpr::Uint16 | port, | |||
| bool | ack | |||
| ) |
Create a ConnectionAck packet to acknowledge a ConnectionRequest.
| host_name | The hostname of the machine that is acknowledging the connection. | |
| port | The port that the acknowledging machine is listening on. | |
| ack | Boolean determining if this is a positive (ACK) or a negative (NACK) responce. |
Definition at line 41 of file ConnectionAck.cpp.
References cluster::Packet::mHeader, cluster::Header::RIM_CONNECTION_ACK, cluster::Header::RIM_PACKET, cluster::Header::RIM_PACKET_HEAD_SIZE, and serialize().
00042 { 00043 // Set the local member variables using the given values. 00044 mHostname = host_name; 00045 mPort = port; 00046 mAck = ack; 00047 00048 // Create a Header for this packet with the correect type and size. 00049 mHeader = new Header(Header::RIM_PACKET, 00050 Header::RIM_CONNECTION_ACK, 00051 Header::RIM_PACKET_HEAD_SIZE 00052 + vpr::BufferObjectReader::STRING_LENGTH_SIZE 00053 + mHostname.size() 00054 + 2 /*mPort*/ 00055 + 1 /*mAck*/, 00056 0/*Field not curently used*/); 00057 // Serialize the given data. 00058 serialize(); 00059 }
| void cluster::ConnectionAck::serialize | ( | ) |
Serializes member variables into a data stream.
Definition at line 61 of file ConnectionAck.cpp.
References cluster::Packet::mHeader, cluster::Packet::mPacketWriter, and cluster::Header::serializeHeader().
Referenced by ConnectionAck().
00062 { 00063 // Clear the data stream. 00064 mPacketWriter->getData()->clear(); 00065 mPacketWriter->setCurPos(0); 00066 00067 // Serialize the header. 00068 mHeader->serializeHeader(); 00069 00070 // Serialize the hostname of the acknowledging node 00071 mPacketWriter->writeString(mHostname); 00072 00073 // Serialize the listening port of the acknowledging node 00074 mPacketWriter->writeUint16(mPort); 00075 00076 // Serialize the Ack boolean 00077 mPacketWriter->writeBool(mAck); 00078 }
| void cluster::ConnectionAck::parse | ( | vpr::BufferObjectReader * | reader | ) | [virtual] |
Parses the data stream into the local member variables.
Implements cluster::Packet.
Definition at line 80 of file ConnectionAck.cpp.
00081 { 00082 // De-Serialize the hostname of the acknowledging node 00083 mHostname = reader->readString(); 00084 00085 // De-Serialize the listening port of the acknowledging node 00086 mPort = reader->readUint16(); 00087 00088 // De-Serialize the Ack boolean 00089 mAck = reader->readBool(); 00090 }
| void cluster::ConnectionAck::printData | ( | int | debug_level | ) | [virtual] |
Print the data to the screen in a readable form.
Implements cluster::Packet.
Definition at line 92 of file ConnectionAck.cpp.
References gadgetDBG_RIM(), and cluster::Packet::printData().
Referenced by gadget::Connector::attemptConnect().
00093 { 00094 vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level) 00095 << clrOutBOLD(clrYELLOW,"==== Connection Ack Packet Data ====\n") << vprDEBUG_FLUSH; 00096 00097 Packet::printData(debug_level); 00098 00099 vprDEBUG(gadgetDBG_RIM,debug_level) 00100 << clrOutBOLD(clrYELLOW, "Host Name: ") << mHostname 00101 << std::endl << vprDEBUG_FLUSH; 00102 vprDEBUG(gadgetDBG_RIM,debug_level) 00103 << clrOutBOLD(clrYELLOW, "Port: ") << mPort 00104 << std::endl << vprDEBUG_FLUSH; 00105 vprDEBUG(gadgetDBG_RIM,debug_level) 00106 << clrOutBOLD(clrYELLOW, "Ack or Nack: ") << (mAck ? "Ack" : "Nack") 00107 << std::endl << vprDEBUG_FLUSH; 00108 00109 vprDEBUG_END(gadgetDBG_RIM,debug_level) 00110 << clrOutBOLD(clrYELLOW,"====================================\n") << vprDEBUG_FLUSH; 00111 }
| static vpr::Uint16 cluster::ConnectionAck::getPacketFactoryType | ( | ) | [inline, static] |
Return the type of this packet.
Definition at line 88 of file ConnectionAck.h.
References cluster::Header::RIM_CONNECTION_ACK.
00089 { 00090 return(Header::RIM_CONNECTION_ACK); 00091 }
| std::string cluster::ConnectionAck::getHostname | ( | ) | [inline] |
Return the hostname of the machine that is acknowledging the connection.
Definition at line 97 of file ConnectionAck.h.
| vpr::Uint16 cluster::ConnectionAck::getPort | ( | ) | [inline] |
Return the port that the acknowledging machine is listening on.
Definition at line 105 of file ConnectionAck.h.
| bool cluster::ConnectionAck::getAck | ( | ) | [inline] |
Return a boolean determining if this is a positive(ACK) or a negative(NACK) responce.
Definition at line 114 of file ConnectionAck.h.
Referenced by gadget::Connector::attemptConnect().
1.5.1