Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern-based registrations/subscriptions #97

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 244 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,247 @@ doc/_doxygen*
CMakeLists.txt.user
*.key
*.pid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the amount of stuff to ignore for VS is ridiculous

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config

# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe

# FAKE - F# Make
.fake/

# JetBrains Rider
.idea/
*.sln.iml
9 changes: 8 additions & 1 deletion autobahn/autobahn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@
#ifndef AUTOBAHN_HPP
#define AUTOBAHN_HPP

#ifdef _WIN32
#define MSGPACK_DISABLE_LEGACY_CONVERT
#define MSGPACK_DEFAULT_API_VERSION 1
#define MSGPACK_DISABLE_LEGACY_CONVERT
#endif

#include "wamp_event.hpp"
#include "wamp_invocation.hpp"
#include "wamp_session.hpp"
#include "wamp_tcp_transport.hpp"
#include "wamp_transport.hpp"
#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
#include "wamp_uds_transport.hpp"

#endif
/*! \mainpage Reference Documentation
*
* Welcome to the reference documentation of <b>Autobahn</b>|Cpp.<br>
Expand Down
72 changes: 72 additions & 0 deletions autobahn/wamp_arguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,78 @@ using wamp_kw_arguments = std::unordered_map<std::string, msgpack::object>;
static const msgpack::object EMPTY_ARGUMENTS(std::array<msgpack::object, 0>(), nullptr);
static const msgpack::object EMPTY_KW_ARGUMENTS(wamp_kw_arguments(), nullptr);


//msgpack map utilities.
//TODO: refactor event & invocation to used these
template <typename T>
inline T value_for_key(const msgpack::object& object, const std::string& key)
{
if (object.type != msgpack::type::MAP) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the size of indentations that the web interface is showing, it appears that this commit uses tabs to indent rather than spaces. This is inconsistent with the code so far and might lead to weird-looking code in some people's editors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Pls no tabs at all.

throw msgpack::type_error();
}
for (std::size_t i = 0; i < object.via.map.size; ++i) {
const msgpack::object_kv& kv = object.via.map.ptr[i];
if (kv.key.type == msgpack::type::STR && key.size() == kv.key.via.str.size
&& key.compare(0, key.size(), kv.key.via.str.ptr, kv.key.via.str.size) == 0)
{
return kv.val.as<T>();
}
}
throw std::out_of_range(key + " keyword argument doesn't exist");
}

template <typename T>
inline T value_for_key(const msgpack::object& object, const char* key)
{
if (m_kw_arguments.type != msgpack::type::MAP) {
throw msgpack::type_error();
}
std::size_t key_size = strlen(key);
for (std::size_t i = 0; i < object.via.map.size; ++i) {
const msgpack::object_kv& kv = object.via.map.ptr[i];
if (kv.key.type == msgpack::type::STR && key_size == kv.key.via.str.size
&& memcmp(key, kv.key.via.str.ptr, key_size) == 0)
{
return kv.val.as<T>();
}
}
throw std::out_of_range(std::string(key) + " keyword argument doesn't exist");
}

template <typename T>
inline T value_for_key_or(const msgpack::object& object, const std::string& key, const T& fallback)
{
if (object.type != msgpack::type::MAP) {
throw msgpack::type_error();
}
for (std::size_t i = 0; i < object.via.map.size; ++i) {
const msgpack::object_kv& kv = object.via.map.ptr[i];
if (kv.key.type == msgpack::type::STR && key.size() == kv.key.via.str.size
&& key.compare(0, key.size(), kv.key.via.str.ptr, kv.key.via.str.size) == 0)
{
return kv.val.as<T>();
}
}
return fallback;
}

template <typename T>
inline T value_for_key_or(const msgpack::object& object, const char* key, const T& fallback)
{
if (object.type != msgpack::type::MAP) {
throw msgpack::type_error();
}
std::size_t key_size = strlen(key);
for (std::size_t i = 0; i < object.via.map.size; ++i) {
const msgpack::object_kv& kv = object.via.map.ptr[i];
if (kv.key.type == msgpack::type::STR && key_size == kv.key.via.str.size
&& memcmp(key, kv.key.via.str.ptr, key_size) == 0)
{
return kv.val.as<T>();
}
}
throw fallback;
}
} // namespace autobahn

#endif // AUTOBAHN_WAMP_ARGUMENTS_HPP
10 changes: 10 additions & 0 deletions autobahn/wamp_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class wamp_event
public:
wamp_event(msgpack::zone&& zone);


//add URI and details
/*!
* Event URI. Used by prefix & wildcard subscriptions
*/
const std::string& uri() const;

/*!
* The number of positional arguments published by the event.
*/
Expand Down Expand Up @@ -186,11 +193,14 @@ class wamp_event

void set_arguments(const msgpack::object& arguments);
void set_kw_arguments(const msgpack::object& kw_arguments);
void set_details(const msgpack::object& details);

private:
msgpack::zone m_zone;
msgpack::object m_arguments;
msgpack::object m_kw_arguments;
std::string m_uri;

};

} // namespace autobahn
Expand Down
Loading