0

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", 
   
} 

AjayKumar
  • 2,812
  • 1
  • 9
  • 28

1 Answers1

2

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’"
  } 
} 

Yan Jin
  • 51
  • 1
  • I would only add that the reply is async. Before sending you have to track your ackId, and maintain state during that time. When the ACK arrives, you have to pull the AckID, and match it to the message you sent, only then will you know that your command was successful or not. For example, you can't start sending messages to the group until the ACK has been received, and the time that takes is not fixed. – codeputer Jan 11 '22 at 05:30