Websocket response parsing

I’m testing a chatting application on websocket with JSON message exchanges. The flow as follow:

  1. Open a websocket URL
  2. Server will send a list of JSON message (in order) in response

(i) Indicate the available presence status

`
{“id”:null,“type”:“PRESENCE_LIST”,
“last”:true
}

`

(ii) Inbox messages to be acknowledge

`
{“id”:null,“type”:“PENDING_CHAT”,
“payload”:{
“entityId”:null,“entityType”:null,“createdDate”:null,
“list”: [{“entityId”:379,“entityType”:“GROUP”,“createdDate”:“10-04-2016 03:21:030”,
“chatMessageId”:5342,“senderId”:434,“senderEntityType”:“USER”,“type”:“GROUP_USER_ADD”,
“data”:[433],“transmissionStatus”:null},
{“entityId”:379,“entityType”:“GROUP”,“createdDate”:“10-04-2016 03:21:080”,
“chatMessageId”:5343,“senderId”:434,“senderEntityType”:“USER”,“type”:“GROUP_USER_ADD”,
“data”:[434],“transmissionStatus”:null}
]
},“last”:true}

`

(iii) Friend list

{"id":622,"type":"PENDING_ENTITY_LIST", "payload":{...} }

(iv) Others Entities

{"id":15441,"type":"RECEIPT_LIST","payload":{...}}

  1. Acknowledge the 2.(ii) for all the chatMessageId (5342, 5343) by sending a JSON message back to the server
  1. Acknowledge the 2.(iv) based on the id (15441) by sending a JSON message back to the server

I’m stuck with the code as follow:

`

.exec(ws(“Connect WS”).open(“/share/chat-service”).pause(3)

.check(wsListen.within(30 seconds).until(4)
.jsonPath(“$.type”).saveAs(“ackTypes”)))

.pause(3)
.foreach(“${ackTypes}”, “ackType”){
exec(ws(“Acknowledge pending message”)…
}

`

I have two questions here:

  1. the ackTypes seem to be null as the execution always come back with the error message "Condition evaluation crashed with message ‘No attribute named ‘ackTypes’ is defined’ "
  2. How to save the “chatMessageId” (5342, 5343) based on the type: “PENDING CHAT”, and the ID (15441) when type: “RECEIPT_LIST”, something like follow:

if type == "PENDING_CHAT" then foreach (mesgId in chatMessageId) { ack mesgId } else if type == "RECEIPT_LIST" then ack id end if

I’m currently using gatling v2.1.7 on a Mac OS 10.11.4. Your help will be greatly appreciated.

Regards,
Joon