Skip to content

Commit d6f288c

Browse files
committed
Dont use tuple to processMessage
Signed-off-by: Nijat K <nijat.khanbabayev@gmail.com>
1 parent 02de663 commit d6f288c

5 files changed

Lines changed: 4 additions & 46 deletions

File tree

cpp/csp/adapters/websocket/ClientInputAdapter.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,8 @@ ClientInputAdapter::ClientInputAdapter(
3232
m_converter = adapters::utils::MessageStructConverterCache::instance().create( type, properties );
3333
};
3434

35-
void ClientInputAdapter::processMessage( void* c, size_t t, PushBatch* batch )
35+
void ClientInputAdapter::processMessage( const std::string& source, void * c, size_t t, PushBatch* batch )
3636
{
37-
38-
if( dataType() -> type() == CspType::Type::STRUCT )
39-
{
40-
auto tick = m_converter -> asStruct( c, t );
41-
pushTick( std::move(tick), batch );
42-
} else if ( dataType() -> type() == CspType::Type::STRING )
43-
{
44-
pushTick( std::string((char const*)c, t), batch );
45-
}
46-
47-
}
48-
49-
void ClientInputAdapter::processMessage( std::tuple<std::string, void*> data, size_t t, PushBatch* batch )
50-
{
51-
// Extract the source string and data pointer from tuple
52-
std::string source = std::get<0>(data);
53-
void* c = std::get<1>(data);
5437
if ( m_dynamic ){
5538
auto& actual_type = static_cast<const CspStructType &>( *dataType() );
5639
auto& nested_type = actual_type.meta()-> field( "msg" ) -> type();

cpp/csp/adapters/websocket/ClientInputAdapter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class ClientInputAdapter final: public PushInputAdapter {
2020
bool dynamic
2121
);
2222

23-
void processMessage( void* c, size_t t, PushBatch* batch );
24-
void processMessage( std::tuple<std::string, void*> data, size_t t, PushBatch* batch );
23+
void processMessage( const std::string& source, void * c, size_t t, PushBatch* batch );
2524

2625
private:
2726
adapters::utils::MessageStructConverterPtr m_converter;

cpp/csp/adapters/websocket/WebsocketEndpointManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void WebsocketEndpointManager::setupEndpoint(const std::string& endpoint_id,
176176
std::vector<uint8_t> data_copy(static_cast<uint8_t*>(data),
177177
static_cast<uint8_t*>(data) + len);
178178
auto tup = std::tuple<std::string, void*>{endpoint_id, data_copy.data()};
179-
m_inputAdapters[consumer_id] -> processMessage( std::move(tup), len, &batch );
179+
m_inputAdapters[consumer_id] -> processMessage( endpoint_id, data_copy.data(), len, &batch );
180180
}
181181
}
182182
});

cpp/csp/python/Conversions.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -666,30 +666,6 @@ inline Dictionary fromPython( PyObject * o )
666666
return out;
667667
}
668668

669-
template<>
670-
inline std::vector<Dictionary> fromPython(PyObject* o)
671-
{
672-
if (!PyList_Check(o))
673-
CSP_THROW(TypeError, "List of dictionaries conversion expected type list got " << Py_TYPE(o)->tp_name);
674-
675-
Py_ssize_t size = PyList_GET_SIZE(o);
676-
std::vector<Dictionary> out;
677-
out.reserve(size);
678-
679-
for (Py_ssize_t i = 0; i < size; ++i)
680-
{
681-
PyObject* item = PyList_GET_ITEM(o, i);
682-
683-
// Skip None values like in Dictionary conversion
684-
if (item == Py_None)
685-
continue;
686-
687-
out.emplace_back(fromPython<Dictionary>(item));
688-
}
689-
690-
return out;
691-
}
692-
693669
template<>
694670
inline std::vector<Dictionary::Data> fromPython( PyObject * o )
695671
{

csp/adapters/websocket_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class WebsocketHeaderUpdate(Struct):
2929
class ConnectionRequest(Struct):
3030
uri: str
3131
action: ActionType = ActionType.CONNECT # Connect, Disconnect, Ping, etc
32-
# Whetehr we maintain the connection
32+
# Whether we maintain the connection
3333
persistent: bool = True # Only relevant for Connect requests
3434
reconnect_interval: timedelta = timedelta(seconds=2)
3535
on_connect_payload: str = "" # message to send on connect

0 commit comments

Comments
 (0)