azure-web-pubsub

Azure JSON subprotocol `json.webpubsub.azure.v1`to join a group fetch responses programmatically


I'm trying obtain programmatically if joining the group was successfully when using json.webpubsub.azure.v1 subprotocol to join a group with a sample.

My sample JSON below, which doesn't fetch outcome success response or error response: Basically, I'm trying to identify if joining the group was successful with the json.webpubsub.azure.v1 subprotocol.

Sample request:


{ 
    "type": "joinGroup", 
    "group": "group1", 
   
} 


Solution

  • Yes, you can, by add “ackId” when joining the group. When the request payload contains “ackId”, the service will return an ack response to the client containing the result for this action. Make sure you use incremental “ackId”s when sending different messages.

    Sample request:

    
    {    
      "type": "joinGroup",    
      "group": "group1",    
      "ackId" : 1 
    } 
    
    

    Sample success response:

    
    {    
      "type": "ack",    
      "success": true,    
      "ackId" : 1 
    } 
    
    

    Sample error response:

    
    {    
      "type": "ack",    
      "success": false,    
      "ackId" : 1,  
      "error": 
      {   
        "name": "Forbidden",  
        "description": "The client does not have permission to join group ‘group1’"
      } 
    }