Skip to content
Merged
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
20 changes: 20 additions & 0 deletions bundles/pubsub/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,23 @@ if (BUILD_PUBSUB_PSA_NANOMSG)
endif ()

endif()

add_celix_container(pubsub_publisher_websocket
GROUP pubsub
BUNDLES
Celix::log_service
Celix::shell
Celix::shell_tui
Celix::http_admin
Celix::pubsub_serializer_json
Celix::pubsub_topology_manager
Celix::pubsub_admin_websocket
celix_pubsub_websocket_publisher
PROPERTIES
PSA_TCP_VERBOSE=true
PUBSUB_ETCD_DISCOVERY_VERBOSE=true
PUBSUB_TOPOLOGY_MANAGER_VERBOSE=true
CELIX_HTTP_ADMIN_LISTENING_PORTS=7660
CELIX_HTTP_ADMIN_NUM_THREADS=5
)
target_link_libraries(pubsub_publisher_websocket PRIVATE ${PUBSUB_CONTAINER_LIBS})
1 change: 1 addition & 0 deletions bundles/pubsub/examples/pubsub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ include_directories("common/include")

add_subdirectory(publisher)
add_subdirectory(publisher2)
add_subdirectory(publisher_websocket)
add_subdirectory(subscriber)


1 change: 0 additions & 1 deletion bundles/pubsub/examples/pubsub/publisher2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ celix_bundle_files(celix_pubsub_poi_publisher2
DESTINATION "META-INF/keys/subscriber"
)

target_link_libraries(celix_pubsub_poi_publisher2 PRIVATE Celix::framework)
60 changes: 60 additions & 0 deletions bundles/pubsub/examples/pubsub/publisher_websocket/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.


find_package(CURL REQUIRED)
find_package(OpenSSL REQUIRED)


add_celix_bundle(celix_pubsub_websocket_publisher
SYMBOLIC_NAME "apache_celix_pubsub_websocket_publisher"
VERSION "1.0.0"
SOURCES
../publisher/private/src/ps_pub_activator.c
../publisher/private/src/pubsub_publisher.c
)
target_link_libraries(celix_pubsub_websocket_publisher PRIVATE Celix::framework Celix::pubsub_api ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
target_include_directories(celix_pubsub_websocket_publisher PRIVATE ../publisher/private/include)


celix_bundle_files(celix_pubsub_websocket_publisher
${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi1.descriptor
${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi2.descriptor
DESTINATION "META-INF/descriptors"
)

celix_bundle_files(celix_pubsub_websocket_publisher
${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi1.properties
${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi2.properties
DESTINATION "META-INF/topics/pub"
)

celix_bundle_files(celix_pubsub_websocket_publisher
${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/publisher
DESTINATION "META-INF/keys"
)

celix_bundle_files(celix_pubsub_websocket_publisher
${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/subscriber/public
DESTINATION "META-INF/keys/subscriber"
)

celix_bundle_add_dir(celix_pubsub_websocket_publisher resources DESTINATION ".")

celix_bundle_headers(celix_pubsub_websocket_publisher
"X-Web-Resource: /example$<SEMICOLON>/resources"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Apache Celix Websocket publisher example</title>
<script src="script.js"></script>
</head>
<body>
<div>
<h1>Poi1 message:</h1>
<br/>
<p id="receivePoi1"></p>
</div>
<br/>
<div>
<h1>Poi2 message:</h1>
<br/>
<p id="receivePoi2"></p>
</div>
<script>docReady();</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

function docReady() {
var host = window.location.host;
var shellSocketP1 = new WebSocket("ws://" + host + "/pubsub/default/poi1");
var shellSocketP2 = new WebSocket("ws://" + host + "/pubsub/default/poi2");

shellSocketP1.onmessage = function (event) {
console.log(event);
var obj = JSON.parse(event.data);
document.getElementById("receivePoi1").innerHTML = "Received " + obj.id + " message with sequence nr: "
+ obj.seqNr + "<br/>latitude = " + JSON.stringify(obj.data.location.lat) + "<br/>longitude = " + JSON.stringify(obj.data.location.lon);
};

shellSocketP2.onmessage = function (event) {
console.log(event);
var obj = JSON.parse(event.data);
document.getElementById("receivePoi2").innerHTML = "Received " + obj.id + " message with sequence nr: "
+ obj.seqNr + "<br/>latitude = " + JSON.stringify(obj.data.location.lat) + "<br/>longitude = " + JSON.stringify(obj.data.location.lon);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,14 @@


struct pubsub_websocket_msg_header {
uint32_t type; //msg type id (hash of fqn)
const char *id; //FQN
uint8_t major;
uint8_t minor;
uint32_t seqNr;
unsigned char originUUID[16];
uint64_t sendtimeSeconds; //seconds since epoch
uint64_t sendTimeNanoseconds; //ns since epoch
};

typedef struct pubsub_websocket_msg_header pubsub_websocket_msg_header_t;

struct pubsub_websocket_msg {
pubsub_websocket_msg_header_t header;
unsigned int payloadSize;
char payload[];
};

typedef struct pubsub_websocket_msg pubsub_websocket_msg_t;

void psa_websocket_setScopeAndTopicFilter(const char* scope, const char *topic, char *filter);
char *psa_websocket_createURI(const char *scope, const char *topic);

Expand Down
Loading