Skip to content

Commit 9f32f7e

Browse files
authored
Add cpp/Chat cmake files (#262)
1 parent 58853ee commit 9f32f7e

18 files changed

+236
-107
lines changed

cpp/Chat/client/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
project(chat_client CXX)
4+
5+
include(../../cmake/common.cmake)
6+
7+
set(common_sources ChatUtils.cpp ChatUtils.h Chat.ice)
8+
9+
add_executable(chatgl2client Client.cpp ChatSession.ice ${common_sources})
10+
slice2cpp_generate(chatgl2client)
11+
target_link_libraries(chatgl2client Ice::Ice Ice::Glacier2)
12+
13+
add_executable(chatpollclient PollingClient.cpp PollingChat.ice ${common_sources})
14+
slice2cpp_generate(chatpollclient)
15+
target_link_libraries(chatpollclient Ice::Ice)

cpp/Chat/client/ChatSession.ice

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
#pragma once
44

5+
#include "Chat.ice"
6+
57
#include <Ice/BuiltinSequences.ice>
68
#include <Glacier2/Session.ice>
7-
#include <Chat.ice>
89

910
module Chat
1011
{

cpp/Chat/client/ChatUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright (c) ZeroC, Inc.
22

3-
#include <Chat.h>
4-
#include <ChatUtils.h>
3+
#include "ChatUtils.h"
4+
#include "Chat.h"
5+
56
#include <array>
67

78
using namespace std;

cpp/Chat/client/PollingChat.ice

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
#pragma once
44

5+
#include "Chat.ice"
6+
57
#include <Ice/BuiltinSequences.ice>
6-
#include <Chat.ice>
78

89
/**
910
*

cpp/Chat/client/PollingClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "ChatUtils.h"
44
#include "PollingChat.h"
5+
56
#include <Ice/Ice.h>
67
#include <chrono>
78
#include <iostream>

cpp/Chat/client/README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Chat Client
2+
13
This demo is a C++ command-line client for the [ZeroC Chat Demo][1].
24
It connects to a single chat room, allowing you to chat with other chat
35
room participants.
@@ -9,11 +11,41 @@ You may run either the Glacier2 client (`chatgl2client`) or the polling client
911
(`chatpollclient`), as well as any username or password to connect.
1012

1113
If you wish to use your own server from the `server` direcory you should specify
12-
the appropriate custom configuration file when launching the client:
14+
the appropriate custom configuration file when launching the client.
15+
16+
To build the demo run:
17+
18+
```shell
19+
cmake -B build -S .
20+
cmake --build build --config Release
21+
```
1322

23+
To run the the Glacier2 client:
24+
25+
**Linux/macOS:**
26+
27+
```shell
28+
./build/chatgl2client --Ice.Config=config.gl2client
1429
```
15-
chatgl2client --Ice.Config=config.gl2client
16-
chatpollclient --Ice.Config=config.pollclient
30+
31+
**Windows:**
32+
33+
```shell
34+
build\Release\chatgl2client --Ice.Config=config.gl2client
35+
```
36+
37+
To run the the Polling client:
38+
39+
**Linux/macOS:**
40+
41+
```shell
42+
./build/chatpollclient --Ice.Config=config.pollclient
43+
```
44+
45+
**Windows:**
46+
47+
```shell
48+
build\Release\chatpollclient --Ice.Config=config.pollclient
1749
```
1850

1951
[1]: https://doc.zeroc.com/display/Doc/Chat+Demo

cpp/Chat/server/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
project(chat_client CXX)
4+
5+
include(../../cmake/common.cmake)
6+
7+
add_executable(chatserver
8+
ChatRoom.cpp ChatRoom.h
9+
ChatServer.cpp
10+
ChatSessionI.cpp ChatSessionI.h
11+
ChatSessionManagerI.cpp ChatSessionManagerI.h
12+
Chat.ice ChatSession.ice
13+
14+
PollingChatSessionFactoryI.cpp PollingChatSessionFactoryI.h
15+
PollingChatSessionI.cpp PollingChatSessionI.h
16+
PollingChat.ice
17+
18+
ChatUtils.cpp ChatUtils.h
19+
)
20+
slice2cpp_generate(chatserver)
21+
target_link_libraries(chatserver Ice::Ice Ice::Glacier2)

cpp/Chat/server/ChatRoom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) ZeroC, Inc.
22

3-
#include <ChatRoom.h>
3+
#include "ChatRoom.h"
44

55
using namespace std;
66

cpp/Chat/server/ChatSession.ice

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
#pragma once
44

5+
#include "Chat.ice"
6+
57
#include <Ice/BuiltinSequences.ice>
68
#include <Glacier2/Session.ice>
7-
#include <Chat.ice>
89

910
module Chat
1011
{

cpp/Chat/server/ChatSessionManagerI.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#ifndef CHAT_SESSION_MANAGER_I_H
44
#define CHAT_SESSION_MANAGER_I_H
55

6-
#include <ChatRoom.h>
6+
#include "ChatRoom.h"
7+
78
#include <Glacier2/Glacier2.h>
89
#include <string>
910

0 commit comments

Comments
 (0)