#include "StdAfx.h"
#include "MeetingConnImpl.h"
#include "Poco/Timestamp.h"
#include "Poco/MD5Engine.h"
#include "MeetingFrameImpl.h"
using Poco::MD5Engine;
using Poco::DigestEngine;
using Poco::Timestamp;
#define BUF_LEN 1024*1024
MeetingConnImpl *MeetingConnImpl:: m_instance = NULL;
MeetingConnImpl *MeetingConnImpl::GetInstance(void)
{
if(m_instance == NULL)
{
m_instance = new MeetingConnImpl();
::atexit(ReleaseALL);
}
return m_instance;
}
MeetingConnImpl::MeetingConnImpl(void)
{
m_ulRoomID = 1;
m_mySessionID = 0;
m_userRole = 4;
m_bHasLogined = false;
m_bHasLoginRoom = false;
m_bLogicServerConnected = false;
m_bRawSockConnected = false;
m_TempRecvBuf = new char[BUF_LEN];
memset(m_strHeadImg,0,sizeof(m_strHeadImg));
memset(m_strUserAccount,0,sizeof(m_strUserAccount));
memset(m_strUserName,0,sizeof(m_strUserName));
memset(m_strServer,0,sizeof(m_strServer));
memset(m_TempRecvBuf,0,sizeof(m_TempRecvBuf));
memset(m_strLogin,0,sizeof(m_strLogin));
m_recvLen = 0;
m_pSock = NULL;
m_mySessionID = 0;
//m_pLogFile = new FileStream("c:\\command.txt");
m_bStop = false;
m_pIMeetingEvent = NULL;
}
MeetingConnImpl::~MeetingConnImpl(void)
{
if(m_TempRecvBuf)
{
delete []m_TempRecvBuf;
m_TempRecvBuf = NULL;
}
//释放这个指针的时候要判断线程是否已经结束了
while(thread.isRunning())
{
Thread::sleep(10);
}
if(m_pSock)
{
delete m_pSock;
m_pSock = NULL;
}
}
void MeetingConnImpl::ReConnect()
{
if(thread.isRunning()||m_bRawSockConnected == true || m_bLogicServerConnected == true ||m_bHasLogined == true )
return;
m_pSock = new StreamSocket();
try
{
if(m_pSock)
{
m_pSock->connectNB(SocketAddress(m_strServer));
}
}
catch (ConnectionRefusedException&)
{
m_pIMeetingEvent->OnNetEvent(NET_EVENT_TIME_OUT,"can't connect to login server");
return ;
}
catch(NetException&)
{
m_pIMeetingEvent->OnNetEvent(NET_EVENT_TIME_OUT,"can't connect to login server");
return ;
}
catch(IOException&)
{
m_pIMeetingEvent->OnNetEvent(NET_EVENT_TIME_OUT,"can't connect to login server");
return ;
}
/* 启动信令接收线程 */
m_bStop = false;
thread.start(*this);
}
long filesize(FILE*stream)
{
long curpos,length;
curpos=ftell(stream);
fseek(stream,0L,SEEK_END);
length=ftell(stream);
fseek(stream,curpos,SEEK_SET);
return length;
}
bool MeetingConnImpl::Connect(char* strServer,IMeetingFrameEvent* pIMeetingEvent)
{
if(thread.isRunning())
return false;
m_bRawSockConnected = false;
if(pIMeetingEvent == NULL)
return false;
m_pIMeetingEvent = pIMeetingEvent;
if(NULL != m_pSock)
{
m_pSock->close();
delete m_pSock;
m_pSock = NULL;
}
m_pSock = new StreamSocket();
strcpy(m_strServer,strServer);
try
{
if(m_pSock)
{
m_pSock->connectNB(SocketAddress(strServer));
}
}
catch (ConnectionRefusedException&)
{
m_pIMeetingEvent->OnNetEvent(NET_EVENT_TIME_OUT,"can't connect to login server");
goto OnError;
}
catch(NetException&)
{
m_pIMeetingEvent->OnNetEvent(NET_EVENT_TIME_OUT,"can't connect to login server");
goto OnError;
}
catch(IOException&)
{
m_pIMeetingEvent->OnNetEvent(NET_EVENT_TIME_OUT,"can't connect to login server");
goto OnError;
}
/* 启动信令接收线程 */
m_bStop = false;
thread.start(*this);
return true;
OnError:
m_pSock->close();
delete m_pSock;
m_pSock = NULL;
return false;
}
void MeetingConnImpl::Release()
{
m_bStop = true;
m_bHasLogined = false;
m_bHasLoginRoom = false;
thread.join();
m_bLogicServerConnected = m_bRawSockConnected = false;
}
//用房间号登录,呢称,房间密码,终端类型
void MeetingConnImpl::LoginWithRoomNo(const char* strUserName, const char* strRoomPassword,uint32_t clientType,uint32_t u32RoomID)
{
//md5
m_tryLoginCount = 0;
m_lastLoginTime = Timestamp();
m_loginType = 2;
m_userRole = 2;
m_ulRoomID = u32RoomID;
//MD5Engine engine;
//engine.update(strRoomPassword);
strcpy(m_strUserAccount, strUserName);
strcpy(m_strUserName, strUserName);
strcpy(m_strPassword,strRoomPassword);
m_clientType = clientType;
if(m_bHasLogined == true)
return;
m_bHasLogined = false;
char utfStr[1024]={0};
sprintf(utfStr, "{\"cmd\":\"loginWithRoomNo\",\"roomID\":%u,\"password\":\"%s\",\"client_type\":%u}\r\n",u32RoomID,m_strPassword,clientType);
strcpy(m_strLogin,utfStr);
}
//用户帐号,密码登入
void MeetingConnImpl::Login(const char* strUserName, const char* strPassword,uint32_t clientType,bool bEncrypt)
{
/*
std::string strTest="[18621066138,18979080001]";
std::string strTest2 = strTest;
Parser parser;
Var result;
try
{
result = parser.parse(strTest2);
Poco::JSON::Array::Ptr array =result.extract<Poco::JSON::Array::Ptr>();
for(Poco::Int32 i = 0; i<array->size();i++)
{
Var item = array->get(i);
unsigned long long phone = item;
cout<<phone;
}
}
catch(JSONException& jsone)
{
//printf("%s \n",buffer);
std::cout << jsone.message() << std::endl;
return;
}
*/
//md5
m_loginType = 1;
m_userRole = 2;
m_tryLoginCount = 0;
m_lastLoginTime = Timestamp();
if(bEncrypt)
{
MD5Engine engine;
engine.update(strPassword);
strcpy(m_strUserAccount, strUserName);
strcpy(m_strPassword, DigestEngine::digestToHex(engine.digest()).data());
}
else
{
strcpy(m_strUserAccount, strUserName);
strcpy(m_strPassword,strPassword);
}
m_clientType = clientType;
if(m_bHasLogined == true)
return;
m_bHasLogined = false;
char utfStr[1024]={0};
sprintf(utfStr, "{\"cmd\":\"login\",\"account\":\"%s\",\"password\":\"%s\",\"client_type\":%u}\r\n",m_strUserAccount,m_strPassword,clientType);
strcpy(m_strLogin,utfStr);
}
//登出
void MeetingConnImpl::Logout()
{
char * msg = new char[64];
strcpy(msg,"{\"cmd\":\"logout\"}\r\n");
FastMutex::ScopedLock autoLock(m_lock);
m_sendBufList.push(msg);
}
void MeetingConnImpl::SendTextMsg(uint64_t toSessionID,char * msg,char* fontName,uint32_t fontSize,uint32_t color,uint64_t flag)
{
std::string msg2 = HTTPCookie::escape(msg);
std::string strFont = HTTPCookie::escape(fontName);
char *utfStr = new char[1024*6];
if(fontName == NULL)
fontName = "";
sprintf(utfStr,"{\"cmd\":\"textChat\",\"fromSessionID\":%I64u,\"fromUserName\":\"%s\",\"toSessionID\":%I64u,\"msg\":\"%s\",\"fontSize\":%u,\"color\":%u,\"flag\":%I64u,\"fontName\":\"%s\",\"roomID\":%u}\r\n",
m_mySessionID,m_strUserName,toSessionID,msg2.data(),fontSize,color,flag,strFont.data(),m_ulRoomID);
FastMutex::ScopedLock autoLock(m_lock);
PMsgItem pMsgItem = new MsgItem();
pMsgItem->ulUserID = toSessionID;
pMsgItem->font_size = fontSize;
pMsgItem->color = color;
pMsgItem->fontFlat = flag;
strcpy(pMsgItem->userName,this->m_strUserName);
strcpy(pMsgItem->msg,msg);
strcpy(pMsgItem->familly,fontName);
//插入到列表
m_chatMsgList.push_back(vector<PMsgItem>::value_type(pMsgItem));
m_sendBufList.push(utfStr);
}
//是否连接
bool MeetingConnImpl::IsConnect()
{
return thread.isRunning();
}
//得到房间列表
void MeetingConnImpl::GetRoomList()
{
char *utfStr = new char[64];
sprintf(utfStr, "{\"cmd\":\"getRoomList\"}\r\n");
FastMutex::ScopedLock autoLock(m_lock);
m_sendBufList.push(utfStr);
}
//得到房间用户列表
void MeetingConnImpl::GetRoomUserList(uint32_t roomID)
{
char *utfStr = new char[64];
sprintf(utfStr, "{\"cmd\":\"getRoomUserList\",\"roomID\":%u}\r\n",roomID);
FastMutex::ScopedLock autoLock(m_lock);
m_sendBufList.push(utfStr);
}
//得到房间信息
void MeetingConnImpl::GetRoomInfo(uint32_t roomID)
{
char *utfStr = new char[128];
sprintf(utfStr, "{\"cmd\":\"getRoomInfo\",\"roomID\":%u}\r\n",roomID);
FastMutex::ScopedLock autoLock(m_lock);
m_sendBufList.push(utfStr);
}
//得到聊天历史记录
void MeetingConnImpl::GetChatHistory(uint32_t roomID)
{
char *utfStr = new char[128];
sprintf(utfStr, "{
没有合适的资源?快使用搜索试试~ 我知道了~
openmeeting2视频会议,仿QQ群视频,实现多人视频,多人语音,文字聊天,表情,共享PPT功能.zip
共1131个文件
h:560个
png:302个
gif:135个
需积分: 0 2 下载量 130 浏览量
2023-12-31
14:37:42
上传
评论
收藏 19.38MB ZIP 举报
温馨提示
openmeeting2视频会议,仿QQ群视频,实现多人视频,多人语音,文字聊天,表情,共享PPT功能,自由发言,主持人控制发言,按F2发言三种语音模式 ,客户端使用vs2010+qt4.85开发,服务器使用php+go语言,数据库采用mysql . QT,C++使用技巧,实战应用开发小系统参考资料,源码参考。 详细介绍了一些Qt框架的各种功能和模块,以及如何使用Qt进行GUI开发、网络编程和跨平台应用开发等。 适用于初学者和有经验的开发者,能够帮助你快速上手Qt并掌握其高级特性。
资源推荐
资源详情
资源评论
收起资源包目录
openmeeting2视频会议,仿QQ群视频,实现多人视频,多人语音,文字聊天,表情,共享PPT功能.zip (1131个子文件)
ZYMediaFrame.h.bak 7KB
MeetingConnImpl.cpp 38KB
MeetingFrameImpl.cpp 36KB
RoomWdg.cpp 19KB
ccommonwidget.cpp 14KB
LeftWdg.cpp 14KB
eventcenter.cpp 14KB
ccommondialog.cpp 13KB
UserLoginWdg.cpp 12KB
DlgAVSetting.cpp 10KB
ConvertDocThread.cpp 9KB
WdgDocShare.cpp 8KB
VideoWin.cpp 7KB
VideoMgr.cpp 7KB
videomonitormain.cpp 6KB
OcImageLoader.cpp 5KB
Meetinglistwdg.cpp 5KB
AppSetting.cpp 4KB
CListItemDelegate.cpp 4KB
ChatListModelDelegate.cpp 3KB
MeetingLoadingWidget.cpp 3KB
SeanThread.cpp 3KB
SpekerTestWdg.cpp 3KB
ButtonDelegate.cpp 3KB
main.cpp 3KB
MicTestWdg.cpp 3KB
ModifyPassWord.cpp 2KB
VoiceTestWdg.cpp 2KB
Meetinglistmodel.cpp 2KB
SeanAnimation.cpp 2KB
stdafx.cpp 2KB
VideoMonitorMgr.cpp 2KB
qupfile.cpp 2KB
qupfile.cpp 2KB
downloadthread.cpp 2KB
ServerAddressSet.cpp 2KB
SeanTestWdg.cpp 2KB
WdgNetInfo.cpp 2KB
OSInfo.cpp 2KB
MeetingDetailDelegate.cpp 1KB
MeetingRoomWordWdg.cpp 1KB
AboutWidget.cpp 1KB
SeanPptProgressWdg.cpp 1KB
SeanGifWdg.cpp 1KB
DlgApplyAdmin.cpp 1KB
autoupdate.cpp 1KB
SeanProgressBar.cpp 1KB
CListModel.cpp 1KB
SeanTableViewDelegate.cpp 1KB
ChatListModel.cpp 926B
ToolBar.cpp 749B
main.cpp 606B
LabelNetInfo.cpp 604B
SeanButton.cpp 465B
dllmain.cpp 393B
RoomSelectWdg.cpp 166B
zlib.def 1KB
zlib.def 1KB
MeetingFrame.def 65B
crashdump.dmp 137KB
CrashRpt1402.exp 3KB
CrashRpt1402d.exp 3KB
ZYMediaFrame.exp 3KB
ZYMediaFrame.exp 3KB
CrashRptProbe1402d.exp 2KB
CrashRptProbe1402.exp 2KB
ZYMediaStream.exp 875B
ZYMediaStream.exp 871B
Meeting.vcxproj.filters 30KB
AutoUpdate.vcxproj.filters 3KB
MeetingFrame.vcxproj.filters 2KB
00453[24x24x8BPP].gif 13KB
00523[24x24x8BPP].gif 13KB
00521[24x24x8BPP].gif 10KB
00434[24x24x8BPP].gif 8KB
00435[24x24x8BPP].gif 8KB
00402[24x24x8BPP].gif 8KB
00450[24x24x8BPP].gif 7KB
00398[24x24x8BPP].gif 6KB
00449[24x24x8BPP].gif 6KB
00421[24x24x8BPP].gif 5KB
00395[24x24x8BPP].gif 5KB
00406[24x24x8BPP].gif 5KB
00502[24x24x8BPP].gif 5KB
00446[24x24x8BPP].gif 5KB
00394[24x24x8BPP].gif 5KB
00469[24x24x8BPP].gif 5KB
00473[24x24x8BPP].gif 4KB
00451[24x24x8BPP].gif 4KB
00392[24x24x8BPP].gif 4KB
00389[24x24x8BPP].gif 4KB
00443[24x24x8BPP].gif 4KB
00491[24x24x8BPP].gif 4KB
00391[24x24x8BPP].gif 4KB
00396[24x24x8BPP].gif 4KB
00400[24x24x8BPP].gif 4KB
00477[24x24x8BPP].gif 4KB
00509[24x24x8BPP].gif 3KB
00412[24x24x8BPP].gif 3KB
00513[24x24x8BPP].gif 3KB
共 1131 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
白话Learning
- 粉丝: 4601
- 资源: 2986
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 运用python生成的跳跃的爱心
- 基于 Java 实现的 Socket.IO 服务器 实时 Java 框架.zip
- 基于 Ant 的 Java 项目示例.zip
- 各种字符串相似度和距离算法的实现Levenshtein、Jaro-winkler、n-Gram、Q-Gram、Jaccard index、最长公共子序列编辑距离、余弦相似度…….zip
- 运用python生成的跳跃的爱心
- 包括用 Java 编写的程序 欢迎您在此做出贡献!.zip
- (源码)基于QT框架的学生管理系统.zip
- 功能齐全的 Java Socket.IO 客户端库,兼容 Socket.IO v1.0 及更高版本 .zip
- 功能性 javascript 研讨会 无需任何库(即无需下划线),只需 ES5 .zip
- 分享Java相关的东西 - Java安全漫谈笔记相关内容.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功