Skip to content

Commit

Permalink
1.服务器端增加配置文件,端口号和数据库账号改为可配置项;2.服务器增加异步日志;3. 协议接口调整,统一在32位机器和64位机器上协议包…
Browse files Browse the repository at this point in the history
…字节数大小
  • Loading branch information
张远龙 committed May 27, 2017
1 parent d49fa23 commit 465c6e0
Show file tree
Hide file tree
Showing 30 changed files with 1,525 additions and 1,126 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
*.opensdf
*.sdf
git提交指令.txt
iKutil.log

# Compiled Object files
*.slo
Expand Down
Binary file added flamingoclient/Bin/CatchScreen.exe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 6,4 @@ filePort=20001
proxyType=0
proxyServer=
proxyPort=
heartbeatinterval=10
Binary file added flamingoclient/CatchScreen/debug/CatchScreen.res
Binary file not shown.
104 changes: 53 additions & 51 deletions flamingoclient/Source/FileTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 15,8 @@
#include "net/protocolstream.h"
#include "net/IUProtocolData.h"

using namespace balloon;

CFileTask::CFileTask(CIUSocket* sockeClient) : m_SocketClient(sockeClient), m_seq(0)
{
m_lpFMGClient = NULL;
Expand Down Expand Up @@ -372,12 374,12 @@ long CFileTask::UploadFile(PCTSTR pszFileName, HWND hwndReflection, HANDLE hCanc
while (true)
{
std::string outbuf;
yt::BinaryWriteStream3 writeStream(&outbuf);
writeStream.Write(msg_type_upload_req);
writeStream.Write(m_seq);
writeStream.Write(szMd5, 32);
writeStream.Write((int)offsetX);
writeStream.Write((int)nFileSize);
BinaryWriteStream writeStream(&outbuf);
writeStream.WriteInt32(msg_type_upload_req);
writeStream.WriteInt32(m_seq);
writeStream.WriteCString(szMd5, 32);
writeStream.WriteInt32((int32_t)offsetX);
writeStream.WriteInt32((int32_t)nFileSize);
size_t eachfilesize = 512* 1024;
if (nFileSize - offsetX < eachfilesize)
eachfilesize = nFileSize - offsetX;
Expand All @@ -387,7 389,7 @@ long CFileTask::UploadFile(PCTSTR pszFileName, HWND hwndReflection, HANDLE hCanc
break;
string filedata;
filedata.append(buffer.GetBuffer(), buffer.GetSize());
writeStream.Write(filedata.c_str(), filedata.length());
writeStream.WriteString(filedata);
writeStream.Flush();
file_msg headerx = { outbuf.length() };
outbuf.insert(0, (const char*)&headerx, sizeof(headerx));
Expand All @@ -413,31 415,31 @@ long CFileTask::UploadFile(PCTSTR pszFileName, HWND hwndReflection, HANDLE hCanc
if (!m_SocketClient->RecvOnFilePort(recvBuf.GetBuffer(), recvBuf.GetSize()))
break;

yt::BinaryReadStream2 readStream(recvBuf.GetBuffer(), recvBuf.GetSize());
int cmd;
if (!readStream.Read(cmd) || cmd != msg_type_upload_resp)
BinaryReadStream readStream(recvBuf.GetBuffer(), recvBuf.GetSize());
int32_t cmd;
if (!readStream.ReadInt32(cmd) || cmd != msg_type_upload_resp)
break;

//int seq;
if (!readStream.Read(m_seq))
if (!readStream.ReadInt32(m_seq))
break;

std::string filemd5;
size_t md5length;
if (!readStream.Read(&filemd5, 0, md5length) || md5length != 32)
if (!readStream.ReadString(&filemd5, 0, md5length) || md5length != 32)
break;

int offset;
if (!readStream.Read(offset))
int32_t offset;
if (!readStream.ReadInt32(offset))
break;

int filesize;
if (!readStream.Read(filesize))
int32_t filesize;
if (!readStream.ReadInt32(filesize))
break;

string dummyfiledata;
size_t filedatalength;
if (!readStream.Read(&dummyfiledata, 0, filedatalength) || filedatalength != 0)
if (!readStream.ReadString(&dummyfiledata, 0, filedatalength) || filedatalength != 0)
break;

if (offset == -1 && filesize == -1)
Expand Down Expand Up @@ -504,16 506,16 @@ long CFileTask::DownloadFile3(LPCSTR lpszFileName, LPCTSTR lpszDestPath, BOOL bO
while (true)
{
std::string outbuf;
yt::BinaryWriteStream3 writeStream(&outbuf);
writeStream.Write(msg_type_download_req);
writeStream.Write(m_seq);
writeStream.Write(lpszFileName, strlen(lpszFileName));
BinaryWriteStream writeStream(&outbuf);
writeStream.WriteInt32(msg_type_download_req);
writeStream.WriteInt32(m_seq);
writeStream.WriteCString(lpszFileName, strlen(lpszFileName));
size_t dummyoffset = 0;
writeStream.Write((int)dummyoffset);
writeStream.WriteInt32((int32_t)dummyoffset);
size_t dummyfilesize = 0;
writeStream.Write((int)dummyfilesize);
writeStream.WriteInt32((int32_t)dummyfilesize);
string dummyfiledata;
writeStream.Write(dummyfiledata.c_str(), dummyfiledata.length());
writeStream.WriteString(dummyfiledata);
writeStream.Flush();

file_msg header = { outbuf.length() };
Expand All @@ -539,46 541,46 @@ long CFileTask::DownloadFile3(LPCSTR lpszFileName, LPCTSTR lpszDestPath, BOOL bO
break;
}

yt::BinaryReadStream2 readStream(buffer.GetBuffer(), recvheader.packagesize);
int cmd;
if (!readStream.Read(cmd) || cmd != msg_type_download_resp)
BinaryReadStream readStream(buffer.GetBuffer(), recvheader.packagesize);
int32_t cmd;
if (!readStream.ReadInt32(cmd) || cmd != msg_type_download_resp)
{
nBreakType = FILE_DOWNLOAD_FAILED;
break;
}

//int seq;
if (!readStream.Read(m_seq))
if (!readStream.ReadInt32(m_seq))
{
nBreakType = FILE_DOWNLOAD_FAILED;
break;
}

std::string filemd5;
size_t md5length;
if (!readStream.Read(&filemd5, 0, md5length) || md5length == 0)
if (!readStream.ReadString(&filemd5, 0, md5length) || md5length == 0)
{
nBreakType = FILE_DOWNLOAD_FAILED;
break;
}

int offset;
if (!readStream.Read(offset))
int32_t offset;
if (!readStream.ReadInt32(offset))
{
nBreakType = FILE_DOWNLOAD_FAILED;
break;
}

int filesize;
if (!readStream.Read(filesize))
int32_t filesize;
if (!readStream.ReadInt32(filesize))
{
nBreakType = FILE_DOWNLOAD_FAILED;
break;
}

string filedata;
size_t filedatalength;
if (!readStream.Read(&filedata, 0, filedatalength) || filedatalength == 0)
if (!readStream.ReadString(&filedata, 0, filedatalength) || filedatalength == 0)
{
nBreakType = FILE_DOWNLOAD_FAILED;
break;
Expand Down Expand Up @@ -700,12 702,12 @@ BOOL CFileTask::UploadUserThumb(PCTSTR pszFileName, HWND hwndReflection, CUpload
while (true)
{
std::string outbuf;
yt::BinaryWriteStream3 writeStream(&outbuf);
writeStream.Write(msg_type_upload_req);
writeStream.Write(m_seq);
writeStream.Write(szMd5, 32);
writeStream.Write((int)offsetX);
writeStream.Write((int)nFileSize);
BinaryWriteStream writeStream(&outbuf);
writeStream.WriteInt32(msg_type_upload_req);
writeStream.WriteInt32(m_seq);
writeStream.WriteCString(szMd5, 32);
writeStream.WriteInt32((int32_t)offsetX);
writeStream.WriteInt32((int32_t)nFileSize);
size_t eachfilesize = 512* 1024;
if (nFileSize - offsetX < eachfilesize)
eachfilesize = nFileSize - offsetX;
Expand All @@ -715,7 717,7 @@ BOOL CFileTask::UploadUserThumb(PCTSTR pszFileName, HWND hwndReflection, CUpload
break;
string filedata;
filedata.append(buffer.GetBuffer(), buffer.GetSize());
writeStream.Write(filedata.c_str(), filedata.length());
writeStream.WriteString(filedata);
writeStream.Flush();
file_msg headerx = { outbuf.length() };
outbuf.insert(0, (const char*)&headerx, sizeof(headerx));
Expand All @@ -741,31 743,31 @@ BOOL CFileTask::UploadUserThumb(PCTSTR pszFileName, HWND hwndReflection, CUpload
if (!m_SocketClient->RecvOnFilePort(recvBuf.GetBuffer(), recvBuf.GetSize()))
break;

yt::BinaryReadStream2 readStream(recvBuf.GetBuffer(), recvBuf.GetSize());
int cmd;
if (!readStream.Read(cmd) || cmd != msg_type_upload_resp)
BinaryReadStream readStream(recvBuf.GetBuffer(), recvBuf.GetSize());
int32_t cmd;
if (!readStream.ReadInt32(cmd) || cmd != msg_type_upload_resp)
break;

//int seq;
if (!readStream.Read(m_seq))
if (!readStream.ReadInt32(m_seq))
break;

std::string filemd5;
size_t md5length;
if (!readStream.Read(&filemd5, 0, md5length) || md5length != 32)
if (!readStream.ReadString(&filemd5, 0, md5length) || md5length != 32)
break;

int offset;
if (!readStream.Read(offset))
int32_t offset;
if (!readStream.ReadInt32(offset))
break;

int filesize;
if (!readStream.Read(filesize))
int32_t filesize;
if (!readStream.ReadInt32(filesize))
break;

string dummyfiledata;
size_t filedatalength;
if (!readStream.Read(&dummyfiledata, 0, filedatalength) || filedatalength != 0)
if (!readStream.ReadString(&dummyfiledata, 0, filedatalength) || filedatalength != 0)
break;

if (offset == -1 && filesize == -1)
Expand Down
8 changes: 4 additions & 4 deletions flamingoclient/Source/LoginSettingsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 111,7 @@ BOOL CLoginSettingsDlg::InitUI()

CIniFile iniFile;
CString strIniPath(g_szHomePath);
strIniPath = _T("config\\iu.ini");
strIniPath = _T("config\\flamingo.ini");
long nSel = iniFile.ReadInt(_T("server"), _T("proxyType"), 0, strIniPath);
if(nSel == -1)
nSel = 0;
Expand Down Expand Up @@ -299,7 299,7 @@ void CLoginSettingsDlg::OnBtn_OK(UINT uNotifyCode, int nID, CWindow wndCtl)

CIniFile iniFile;
CString strIniPath(g_szHomePath);
strIniPath = _T("config\\iu.ini");
strIniPath = _T("config\\flamingo.ini");
iniFile.WriteString(_T("server"), _T("server"), m_szSrvAddr, strIniPath);
iniFile.WriteString(_T("server"), _T("fileserver"), m_szFileSrvAddr, strIniPath);
iniFile.WriteString(_T("server"), _T("port"), m_szSrvPort, strIniPath);
Expand All @@ -314,8 314,8 @@ void CLoginSettingsDlg::OnBtn_OK(UINT uNotifyCode, int nID, CWindow wndCtl)

m_pClient->SetServer(m_szSrvAddr);
m_pClient->SetFileServer(m_szFileSrvAddr);
m_pClient->SetPort(_wtol(m_szSrvPort));
m_pClient->SetFilePort(_wtol(m_szFilePort));
m_pClient->SetPort((short)_wtol(m_szSrvPort));
m_pClient->SetFilePort((short)_wtol(m_szFilePort));
//m_pClient->m_IUProtocol.SetProxyType(nCurSel);
//if(nCurSel > USE_BROWSER_PROXY)
//{
Expand Down
4 changes: 2 additions & 2 deletions flamingoclient/Source/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5262,7 5262,7 @@ void CMainDlg::SaveCurrentLogonUserToFile()
{
CIniFile iniFile;
CString strIniFile;
strIniFile.Format(_T("%sconfig\\iu.ini"), g_szHomePath);
strIniFile.Format(_T("%sconfig\\flamingo.ini"), g_szHomePath);
CString strAccountList;
iniFile.ReadString(_T("LogonUserList"), _T("AccountName"), _T(""), strAccountList.GetBuffer(256), 256, strIniFile);
strAccountList.ReleaseBuffer();
Expand All @@ -5275,7 5275,7 @@ void CMainDlg::DeleteCurrentUserFromFile()
{
CIniFile iniFile;
CString strIniFile;
strIniFile.Format(_T("%sconfig\\iu.ini"), g_szHomePath);
strIniFile.Format(_T("%sconfig\\flamingo.ini"), g_szHomePath);
CString strAccountList;
iniFile.ReadString(_T("LogonUserList"), _T("AccountName"), _T(""), strAccountList.GetBuffer(256), 256, strIniFile);
strAccountList.ReleaseBuffer();
Expand Down
21 changes: 13 additions & 8 deletions flamingoclient/Source/RecvMsgThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 10,8 @@
#include "FlamingoClient.h"
#include "IULog.h"

using namespace balloon;

// "/f["系统表情id"] /c["自定义表情文件名"] /o[字体名称,大小,颜色,加粗,倾斜,下划线]"
tstring FormatContent(std::vector<CContent*>& arrContent)
{
Expand Down Expand Up @@ -304,28 306,31 @@ void CRecvMsgThread::EnableUI(bool bEnable)

BOOL CRecvMsgThread::HandleMessage(const std::string& strMsg)
{
yt::BinaryReadStream2 readStream(strMsg.c_str(), strMsg.length());
int cmd;
if (!readStream.Read(cmd))
BinaryReadStream readStream(strMsg.c_str(), strMsg.length());
int32_t cmd;
if (!readStream.ReadInt32(cmd))
{
return false;
}

//int seq;
if (!readStream.Read(m_seq))
if (!readStream.ReadInt32(m_seq))
{
return false;
}

std::string data;
size_t datalength;
if (!readStream.Read(&data, 0, datalength))
if (!readStream.ReadString(&data, 0, datalength))
{
return false;
}

switch (cmd)
{
//心跳包不处理
case msg_type_heartbeart:
break;
//注册
case msg_type_register:
HandleRegisterMessage(data);
Expand Down Expand Up @@ -355,7 360,7 @@ BOOL CRecvMsgThread::HandleMessage(const std::string& strMsg)
{
int32_t targetId;
//int seq;
if (!readStream.Read(targetId))
if (!readStream.ReadInt32(targetId))
{
break;
}
Expand Down Expand Up @@ -384,13 389,13 @@ BOOL CRecvMsgThread::HandleMessage(const std::string& strMsg)
{
int32_t senderId;
//int seq;
if (!readStream.Read(senderId))
if (!readStream.ReadInt32(senderId))
{
break;
}

int32_t targetid;
if (!readStream.Read(targetid))
if (!readStream.ReadInt32(targetid))
{
break;
}
Expand Down
2 changes: 1 addition & 1 deletion flamingoclient/Source/RecvMsgThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 185,7 @@ class CRecvMsgThread : public CThread

UINT m_nPreMsgId, m_nPreMsgId2;

int m_seq;
int32_t m_seq;

HWND m_hProxyWnd;
};
Loading

0 comments on commit 465c6e0

Please sign in to comment.