PJoinDataNodeREQ.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:1k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // PJoinDataNodeREQ.cpp: implementation of the PJoinDataNodeREQ class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "PJoinDataNodeREQ.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- PJoinDataNodeREQ::PJoinDataNodeREQ()
- {
- this->Tag = PJoinDataNodeREQTAG;
- this->user_id = 0;
- this->user_name = "";
- this->conference_name = "";
- }
- PJoinDataNodeREQ::~PJoinDataNodeREQ()
- {
- }
- bool PJoinDataNodeREQ::assembleData( int user_id , const char * username , const char * c_name )
- {
- this->buffer.Resize( 3 * INT_SIZE + strlen( username ) + CHAR_SIZE + strlen( c_name ) + CHAR_SIZE );
- char * now = this->buffer.GetBuffer( );
- *( int * )now = this->buffer.GetSize( ); now += INT_SIZE;
- *( int * )now = this->Tag; now += INT_SIZE;
- *( int * )now = user_id; now += INT_SIZE;
- strcpy( now , username ); now += strlen( username ) + CHAR_SIZE;
- strcpy( now , c_name );
- return true;
- }
- bool PJoinDataNodeREQ::parseData( CBuffer & buffer )
- {
- if( ! buffer.GetSize( ) ) return false;
- char * now = buffer.GetBuffer( ) + 2 * INT_SIZE;
- this->user_id = *( int * )now ; now += INT_SIZE;
- this->user_name = now; now += this->user_name.length( ) + CHAR_SIZE;
- this->conference_name = now;
- return true;
- }