Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Readme.md

Publish and subscribe messages

Prerequisites

Copy the ConnectionString from portal

Copy Connection String from Keys tab of the created Azure Web PubSub service to be used later. connection string

Run the streaming web server

Open a new terminal window, copy Connection String from Keys tab of the created Azure Web PubSub service, run the below command with the <connection-string> replaced by your Connection String:

cd logstream-webserver
mvn compile & mvn package & mvn exec:java -Dexec.mainClass="com.webpubsub.tutorial.App" -Dexec.cleanupDaemonThreads=false -Dexec.args="'<connection_string>'"

Now open http://localhost:8080 in browser. If you are using Chrome, you can press F12 or right-click -> Inspect -> Developer Tools, and select the Network tab. Load the web page, and you can see the WebSocket connection is established. Click to inspect the WebSocket connection, you can see below connected event message is received in client. You can see that you can get the connectionId generated for this client.

{"type":"system","event":"connected","userId":null,"connectionId":"<the_connection_id>"}

Run the streaming console app

Start a new terminal window:

cd logstream-streaming
mvn compile & mvn package & mvn exec:java -Dexec.mainClass="com.webpubsub.quickstart.App" -Dexec.cleanupDaemonThreads=false

Type any text and they'll be displayed in the browser in real time.