Chat with WebSockets Messages API - JavaScript
This sample shows how to publish and subscribe to messages from a JavaScript browser application.
The sample gets a token from IDP, connects to the messaging service, subscribes and publishes messages.
Open the sample in two different tabs and send messages between them. You can also test the sample with a Chat plugin sample running in another XProtect component like Smart Client (see mipsdk-samples-plugin/ChatWithWebsockets).
This sample is not production ready and has been kept simple in purpose. Learn about:
To learn more about the WebSockets Messages API, read the full docs.
Prerequisites
- XProtect 2023 R2 or later.
- The API Gateway installed on the same host as the management server.
- The API Gateway configured to allow CORS.
- A basic user.
The sample demonstrates
- How to login using OpenID Connect/OAuth2 from a JavaScript application
- How to subscribe to message topics
- How to publish messages
- How to send pulse messages
Using
- WebSockets Messages API
Related samples
- mipsdk-samples-plugin/ChatWithWebsockets
Environment
- None