Skip to content

Commit 4e5559a

Browse files
Added reverse subscribe sample
1 parent ff0dd81 commit 4e5559a

File tree

6 files changed

+496
-0
lines changed

6 files changed

+496
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//******************************************************************************************************
2+
// ReverseSubscribe.cpp - Gbtc
3+
//
4+
// Copyright © 2019, Grid Protection Alliance. All Rights Reserved.
5+
//
6+
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
7+
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
8+
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
9+
// file except in compliance with the License. You may obtain a copy of the License at:
10+
//
11+
// http://opensource.org/licenses/MIT
12+
//
13+
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
14+
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
15+
// License for the specific language governing permissions and limitations.
16+
//
17+
// Code Modification History:
18+
// ----------------------------------------------------------------------------------------------------
19+
// 03/27/2018 - J. Ritchie Carroll
20+
// Generated original version of source code.
21+
//
22+
//******************************************************************************************************
23+
24+
#include <iostream>
25+
#include "SubscriberHandler.h"
26+
#include "../../lib/Convert.h"
27+
28+
using namespace std;
29+
using namespace sttp;
30+
using namespace sttp::transport;
31+
32+
SubscriberHandler* Subscriber;
33+
34+
int main(int argc, char* argv[])
35+
{
36+
uint16_t port;
37+
38+
// Ensure that the necessary
39+
// command line arguments are given.
40+
if (argc < 2)
41+
{
42+
cout << "Usage:" << endl;
43+
cout << " ReverseSubscribe PORT" << endl;
44+
return 0;
45+
}
46+
47+
// Get port.
48+
stringstream(argv[1]) >> port;
49+
50+
// Initialize the subscriber.
51+
// Maintain the life-time of SubscriberHandler instances within main
52+
Subscriber = new SubscriberHandler();
53+
54+
Subscriber->SetFilterExpression(SubscriberInstance::SubscribeAllNoStatsExpression);
55+
56+
// In this example we also specify a meta-data filtering expression:
57+
//Subscriber->SetMetadataFilters(SubscriberInstance::FilterMetadataStatsExpression);
58+
59+
// The following line of code is the only thing special about a data subscriber
60+
// in reverse connection mode, i.e., execute a listen instead of a connect:
61+
if (Subscriber->Listen(port))
62+
Subscriber->StatusMessage("Listening on port " + ToString(port));
63+
else
64+
Subscriber->ErrorMessage("Failed to listen on port " + ToString(port));
65+
66+
// Wait until the user presses enter before quitting.
67+
string line;
68+
getline(cin, line);
69+
70+
// Shutdown subscriber instance
71+
Subscriber->Disconnect();
72+
73+
// Disconnect the subscriber to stop background threads.
74+
cout << "Disconnected." << endl;
75+
76+
// Delete subscriber instance
77+
delete Subscriber;
78+
79+
return 0;
80+
}
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Debug|x64">
9+
<Configuration>Debug</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Release|Win32">
13+
<Configuration>Release</Configuration>
14+
<Platform>Win32</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<ProjectGuid>{08919E93-D481-493A-9FEA-96A1D66752F7}</ProjectGuid>
23+
<Keyword>Win32Proj</Keyword>
24+
<RootNamespace>ReverseSubscribe</RootNamespace>
25+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
26+
<ProjectName>ReverseSubscribe</ProjectName>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>true</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<CharacterSet>Unicode</CharacterSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
42+
<ConfigurationType>Application</ConfigurationType>
43+
<UseDebugLibraries>false</UseDebugLibraries>
44+
<PlatformToolset>v143</PlatformToolset>
45+
<WholeProgramOptimization>true</WholeProgramOptimization>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<OutDir>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\samples\</OutDir>
75+
<IntDir>obj\$(Configuration)\</IntDir>
76+
<LibraryPath>$(SolutionDir)\..\..\boost\stage\lib\;$(LibraryPath)</LibraryPath>
77+
</PropertyGroup>
78+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
79+
<OutDir>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\samples\</OutDir>
80+
<IntDir>obj\$(Configuration)\</IntDir>
81+
<LibraryPath>$(SolutionDir)\..\..\boost\stage\lib\;$(LibraryPath)</LibraryPath>
82+
</PropertyGroup>
83+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
84+
<OutDir>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\samples\</OutDir>
85+
<IntDir>obj\$(Configuration)\</IntDir>
86+
<LibraryPath>$(SolutionDir)\..\..\boost\stage\lib\;$(LibraryPath)</LibraryPath>
87+
<LinkIncremental>false</LinkIncremental>
88+
</PropertyGroup>
89+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
90+
<OutDir>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\samples\</OutDir>
91+
<IntDir>obj\$(Configuration)\</IntDir>
92+
<LibraryPath>$(SolutionDir)\..\..\boost\stage\lib\;$(LibraryPath)</LibraryPath>
93+
<LinkIncremental>false</LinkIncremental>
94+
</PropertyGroup>
95+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
96+
<ClCompile>
97+
<PrecompiledHeader>
98+
</PrecompiledHeader>
99+
<WarningLevel>Level3</WarningLevel>
100+
<Optimization>Disabled</Optimization>
101+
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;WIN32;BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE;USE_UTF8_INSTEAD_OF_CODECVT;_HAS_AUTO_PTR_ETC;_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
102+
<SDLCheck>true</SDLCheck>
103+
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\boost</AdditionalIncludeDirectories>
104+
<LanguageStandard>stdcpplatest</LanguageStandard>
105+
</ClCompile>
106+
<Link>
107+
<SubSystem>Console</SubSystem>
108+
<GenerateDebugInformation>true</GenerateDebugInformation>
109+
<AdditionalDependencies>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\lib\sttp.cpp.lib;%(AdditionalDependencies)</AdditionalDependencies>
110+
</Link>
111+
</ItemDefinitionGroup>
112+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
113+
<ClCompile>
114+
<PrecompiledHeader>
115+
</PrecompiledHeader>
116+
<WarningLevel>Level3</WarningLevel>
117+
<Optimization>Disabled</Optimization>
118+
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;WIN32;BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE;USE_UTF8_INSTEAD_OF_CODECVT;_HAS_AUTO_PTR_ETC;_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119+
<SDLCheck>true</SDLCheck>
120+
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\boost</AdditionalIncludeDirectories>
121+
<LanguageStandard>stdcpplatest</LanguageStandard>
122+
</ClCompile>
123+
<Link>
124+
<SubSystem>Console</SubSystem>
125+
<GenerateDebugInformation>true</GenerateDebugInformation>
126+
<AdditionalDependencies>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\lib\sttp.cpp.lib;%(AdditionalDependencies)</AdditionalDependencies>
127+
</Link>
128+
</ItemDefinitionGroup>
129+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
130+
<ClCompile>
131+
<WarningLevel>Level3</WarningLevel>
132+
<PrecompiledHeader>
133+
</PrecompiledHeader>
134+
<Optimization>MaxSpeed</Optimization>
135+
<FunctionLevelLinking>true</FunctionLevelLinking>
136+
<IntrinsicFunctions>true</IntrinsicFunctions>
137+
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;WIN32;BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE;USE_UTF8_INSTEAD_OF_CODECVT;_HAS_AUTO_PTR_ETC;_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
138+
<SDLCheck>true</SDLCheck>
139+
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\boost</AdditionalIncludeDirectories>
140+
<LanguageStandard>stdcpplatest</LanguageStandard>
141+
</ClCompile>
142+
<Link>
143+
<SubSystem>Console</SubSystem>
144+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
145+
<OptimizeReferences>true</OptimizeReferences>
146+
<GenerateDebugInformation>true</GenerateDebugInformation>
147+
<AdditionalDependencies>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\lib\sttp.cpp.lib;%(AdditionalDependencies)</AdditionalDependencies>
148+
</Link>
149+
</ItemDefinitionGroup>
150+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
151+
<ClCompile>
152+
<WarningLevel>Level3</WarningLevel>
153+
<PrecompiledHeader>
154+
</PrecompiledHeader>
155+
<Optimization>MaxSpeed</Optimization>
156+
<FunctionLevelLinking>true</FunctionLevelLinking>
157+
<IntrinsicFunctions>true</IntrinsicFunctions>
158+
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;WIN32;BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE;USE_UTF8_INSTEAD_OF_CODECVT;_HAS_AUTO_PTR_ETC;_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
159+
<SDLCheck>true</SDLCheck>
160+
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\boost</AdditionalIncludeDirectories>
161+
<LanguageStandard>stdcpplatest</LanguageStandard>
162+
</ClCompile>
163+
<Link>
164+
<SubSystem>Console</SubSystem>
165+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
166+
<OptimizeReferences>true</OptimizeReferences>
167+
<GenerateDebugInformation>true</GenerateDebugInformation>
168+
<AdditionalDependencies>$(SolutionDir)..\build\output\$(PlatformTarget)\$(Configuration)\lib\sttp.cpp.lib;%(AdditionalDependencies)</AdditionalDependencies>
169+
</Link>
170+
</ItemDefinitionGroup>
171+
<ItemGroup>
172+
<ClCompile Include="SubscriberHandler.cpp" />
173+
<ClCompile Include="ReverseSubscribe.cpp" />
174+
</ItemGroup>
175+
<ItemGroup>
176+
<ClInclude Include="SubscriberHandler.h" />
177+
</ItemGroup>
178+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
179+
<ImportGroup Label="ExtensionTargets">
180+
</ImportGroup>
181+
</Project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CppProjectProperties/LanguageStandard/@EntryValue">Cpp20</s:String></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)