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