Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a0b350c

Browse files
committed
20191003 서버에 Redis 조회, 입력 추가
1 parent 7fce586 commit a0b350c

File tree

7 files changed

+65
-13
lines changed

7 files changed

+65
-13
lines changed

‎Chat/Client/Client.cpp‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ unsigned WINAPI SendMsgThread(void *arg) {
296296
else if (msg.compare("8") == 0) { // 로그아웃
297297
direction = LOG_OUT;
298298
}
299-
else if (msg.compare("9") == 0) { // 콘솔지우기
299+
else if (msg.compare("9") == 0) { // 인기도조회
300+
direction = USER_GOOD_INFO;
301+
}
302+
else if (msg.compare("10") == 0) { // 콘솔지우기
300303
system("cls");
301304
cout << waitRoomMessage << endl;
302305
continue;
@@ -308,6 +311,11 @@ unsigned WINAPI SendMsgThread(void *arg) {
308311
cout << chatRoomMessage << endl;
309312
continue;
310313
}
314+
else if (msg.find("\\good") != -1) { // 인기도
315+
cout << "인기도를 줄 닉네임을 입력하세요" << endl;
316+
getline(cin, msg);
317+
direction = USER_GOOD;
318+
}
311319
else if (msg.find("\\send") != -1) { // 파일전송
312320
cout << "파일 경로를 입력해 주세요" << endl;
313321
string fileDir;

‎Chat/Client/common.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ enum Direction {
5050
FRIEND_DELETE,
5151
LOG_OUT,
5252
FILE_SEND,
53+
USER_GOOD,
54+
USER_GOOD_INFO,
5355
MAX,
5456
};
5557

@@ -61,9 +63,9 @@ enum LoginCheck {
6163
};
6264

6365
#define loginBeforeMessage "1.계정생성 2.로그인하기 3.종료 4.콘솔지우기"
64-
#define waitRoomMessage "1.방 정보 보기 2.방 만들기 3.방 입장하기 4.유저 정보 5.친구 정보 6.친구 관리 7.귓속말 8.로그아웃 9.콘솔지우기"
66+
#define waitRoomMessage "1.방 정보 보기 2.방 만들기 3.방 입장하기 4.유저 정보 5.친구 정보 6.친구 관리 7.귓속말 8.로그아웃 9.인기도 조회 10.콘솔지우기"
6567
#define errorMessage "잘못된 명령어 입니다"
66-
#define chatRoomMessage "나가시려면 \\out을 콘솔지우기는 \\clear를 친구추가는 \\add 닉네임을 파일전송은\\send를 입력하세요"
68+
#define chatRoomMessage "나가시려면 \\out을 콘솔지우기는 \\clear를 친구추가는 \\add 닉네임을 파일전송은\\send를 유저인기도는\\good을 입력하세요"
6769

6870
#define SERVER_IP "172.30.1.23"
6971
#define SERVER_PORT "1234"

‎Chat/Server/BusinessService.cpp‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ namespace BusinessService {
1212
BusinessService::BusinessService() {
1313

1414
// 임계영역 Object 생성
15-
InitializeCriticalSectionAndSpinCount(&idCs, 2000);
15+
InitializeCriticalSection(&idCs);
1616

17-
InitializeCriticalSectionAndSpinCount(&userCs, 2000);
17+
InitializeCriticalSection(&userCs);
1818

19-
InitializeCriticalSectionAndSpinCount(&roomCs, 2000);
19+
InitializeCriticalSection(&roomCs);
2020

2121
iocpService = new IocpService::IocpService();
2222

@@ -783,6 +783,19 @@ namespace BusinessService {
783783
string sendMsg = loginBeforeMessage;
784784
InsertSendQueue(SendTo::SEND_ME, sendMsg, "", sock, ClientStatus::STATUS_LOGOUT);
785785
}
786+
else if (direction == Direction::USER_GOOD_INFO) { // 인기도 조회
787+
vector<RankVo> vec = move(Redis::GetInstance()->Zrevrange("pl", 20));
788+
string sendMsg = "인기도 리스트";
789+
vector<RankVo>::iterator iter;
790+
for (iter = vec.begin(); iter != vec.end(); iter++)
791+
{
792+
sendMsg += "\n";
793+
sendMsg += iter->getNickName();
794+
sendMsg += " :";
795+
sendMsg += to_string(iter->getPoint());
796+
}
797+
InsertSendQueue(SendTo::SEND_ME, sendMsg, "", sock, ClientStatus::STATUS_WAITING);
798+
}
786799
else { // 그외 명령어 입력
787800
string sendMsg = errorMessage;
788801
sendMsg += waitRoomMessage;
@@ -862,6 +875,34 @@ namespace BusinessService {
862875
// 친구추가
863876
AddFriend(sock, msg, id, ClientStatus::STATUS_CHATTIG);
864877
}
878+
else if (direction == USER_GOOD) { // 인기도
879+
880+
// 방이름 임시 저장
881+
string roomName = string(userMap.find(sock)->second.roomName);
882+
883+
EnterCriticalSection(&userCs);
884+
unordered_map<SOCKET, PER_HANDLE_DATA> userCopyMap = userMap; // 로그인된 친구정보 확인위해 복사
885+
LeaveCriticalSection(&userCs);
886+
887+
unordered_map<SOCKET, PER_HANDLE_DATA>::const_iterator iter;
888+
bool find = false;
889+
for (iter = userCopyMap.begin(); iter != userCopyMap.end(); iter++) {
890+
if (strcmp(msg.c_str(), iter->second.userName) == 0) {
891+
Redis::GetInstance()->Zincr("pl", msg);
892+
find = true;
893+
break;
894+
}
895+
}
896+
897+
if (find) {
898+
string sendMsg = "인기도 추천 성공\n";
899+
InsertSendQueue(SendTo::SEND_ME, sendMsg, "", sock, ClientStatus::STATUS_CHATTIG);
900+
}
901+
else {
902+
string sendMsg = "인기도 추천 실패\n";
903+
InsertSendQueue(SendTo::SEND_ME, sendMsg, "", sock, ClientStatus::STATUS_CHATTIG);
904+
}
905+
}
865906
else { // 채팅방에서 채팅중
866907

867908
string sendMsg;

‎Chat/Server/BusinessService.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "IocpService.h"
2020
#include "FileService.h"
2121
#include "Dao.h"
22+
#include "Redis.h"
2223

23-
// #pragma comment(lib, "Dao.h")
2424

2525
// SQLwork에게 전달할 정보들
2626
enum class SqlWork{

‎Chat/Server/common.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ enum Direction {
4545
FRIEND_DELETE,
4646
LOG_OUT,
4747
FILE_SEND,
48+
USER_GOOD,
49+
USER_GOOD_INFO,
4850
MAX,
4951

5052
// Node 관리콘솔에서 보낼 메세지
@@ -69,7 +71,7 @@ enum class SendTo {
6971
};
7072

7173
#define loginBeforeMessage "1.계정생성 2.로그인하기 3.종료 4.콘솔지우기"
72-
#define waitRoomMessage "1.방 정보 보기 2.방 만들기 3.방 입장하기 4.유저 정보 5.친구 정보 6.친구 관리 7.귓속말 8.로그아웃 9.콘솔지우기"
74+
#define waitRoomMessage "1.방 정보 보기 2.방 만들기 3.방 입장하기 4.유저 정보 5.친구 정보 6.친구 관리 7.귓속말 8.로그아웃 9.인기도 조회 10.콘솔지우기"
7375
#define errorMessage "잘못된 명령어 입니다"
7476
#define chatRoomMessage "나가시려면 \\out을 콘솔지우기는 \\clear를 친구추가는 \\add 닉네임을 파일전송은\\send를 유저인기도는\\good을 입력하세요"
7577

‎Server/Server/Server.vcxproj‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
@@ -51,7 +51,7 @@
5151
<VCProjectVersion>16.0</VCProjectVersion>
5252
<ProjectGuid>{216C8324-B0E9-4CE0-945A-659627F0A75F}</ProjectGuid>
5353
<RootNamespace>Server</RootNamespace>
54-
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
54+
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
5555
</PropertyGroup>
5656
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
5757
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -76,7 +76,7 @@
7676
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
7777
<ConfigurationType>Application</ConfigurationType>
7878
<UseDebugLibraries>false</UseDebugLibraries>
79-
<PlatformToolset>v142</PlatformToolset>
79+
<PlatformToolset>v140</PlatformToolset>
8080
<WholeProgramOptimization>true</WholeProgramOptimization>
8181
<CharacterSet>MultiByte</CharacterSet>
8282
</PropertyGroup>
@@ -163,7 +163,6 @@
163163
<IgnoreSpecificDefaultLibraries>libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
164164
<ModuleDefinitionFile>
165165
</ModuleDefinitionFile>
166-
<AdditionalOptions>/FORCE:multiple %(AdditionalOptions)</AdditionalOptions>
167166
</Link>
168167
</ItemDefinitionGroup>
169168
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

‎Server/Server/conf/SqlConnection.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
172.30.1.12
1+
172.30.1.36
22
1433
33
server_DB
44
23460

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /