PBroadcastREQ.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:1k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // PBroadcastREQ.cpp: implementation of the PBroadcastREQ class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "PBroadcastREQ.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- PBroadcastREQ::PBroadcastREQ( )
- {
- this->Tag = PBroadcastREQTAG;
- this->broadcast_user_id = 0;
- this->recv_user_id = 0;
- this->header = NULL;
- this->header_size = 0;
- }
- PBroadcastREQ::~PBroadcastREQ( )
- {
- }
- bool PBroadcastREQ::assembleData( int broadcast_user_id , int recv_user_id , char * header , int size )
- {
- this->buffer.Resize( 5 * INT_SIZE + size );
- char * now = this->buffer.GetBuffer( );
- *( int * )now = this->buffer.GetSize( ); now += INT_SIZE;
- *( int * )now = this->Tag; now += INT_SIZE;
- *( int * )now = broadcast_user_id; now += INT_SIZE;
- *( int * )now = recv_user_id; now += INT_SIZE;
- *( int * )now = size ; now += INT_SIZE;
- if( size > 0 )
- memcpy( now , header , size );
- return true;
- }
- bool PBroadcastREQ::parseData( CBuffer & buffer )
- {
- if( ! buffer.GetSize( ) ) return false;
- char * now = buffer.GetBuffer( ) + 2 * INT_SIZE;
- this->broadcast_user_id = *( int * )now; now += INT_SIZE;
- this->recv_user_id = *( int * )now; now += INT_SIZE;
- this->header_size = *( int * )now; now += INT_SIZE;
- this->header = this->header_size > 0 ? now : NULL;
- return true;
- }