PSendFileREQ.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:2k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // PSendFileREQ.cpp: implementation of the PSendFileREQ class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "PSendFileREQ.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- PSendFileREQ::PSendFileREQ()
- {
- this->Tag = PSendFileREQTAG;
- this->user_name = "";
- this->user_id = 0;
- this->filename = "";
- this->recv_id = 0;
- }
- PSendFileREQ::~PSendFileREQ()
- {
- }
- bool PSendFileREQ::assembleData( const char * user_name , int user_id , const char * filename , int recv_id )
- {
- this->buffer.Resize( sizeof( int ) + strlen( user_name ) + sizeof( char ) + sizeof( int ) + strlen( filename ) + sizeof( char ) + sizeof( int ) );
- char * now = buffer.GetBuffer( );
- *( int * )now = this->Tag; now += sizeof( int );
- strcpy( now , user_name ); now += strlen( user_name ) + sizeof( char );
- *( int * )now = user_id ; now += sizeof( int );
- strcpy( now , filename ); now += strlen( filename ) + sizeof( char );
- *( int * )now = recv_id;
- return true;
- }
- bool PSendFileREQ::parseData( char * buffer , int size )
- {
- if( *( int * )buffer != this->Tag )
- return false;
- buffer += sizeof( int );
- this->user_name = buffer; buffer += this->user_name.GetLength( ) + sizeof( char );
- this->user_id = *( int * )buffer; buffer += sizeof( int );
- this->filename = buffer; buffer += this->filename.GetLength( ) + sizeof( char );
- this->recv_id = *( int * )buffer;
- return true;
- }