This event is used to establish a network connection to the Chrome DevTools Protocol (CDP).
*PageData = EventData()
NewList PageData.PAGE_DATA()
If Cr_WebSocket_PageData(*PageData, PageData())
If Not Connection
LastElement(PageData())
PageID$ = PageData()\id
Connection = Cr_WebSocket_Connect(PageID$)
EndIf
EndIf
FreeList(PageData())
When a disconnection occurs, there are three possible approaches:
Protocol events can be categorized into two types:
Guidelines for processing protocol events:
JSONEvent = EventData()
JSONValue = JSONValue(JSONEvent)
If JSONType(JSONValue) = #PB_JSON_Object
If ExamineJSONMembers(JSONValue)
If NextJSONMember(JSONValue)
JSONMemberValue = JSONMemberValue(JSONValue)
Select JSONType(JSONMemberValue)
Case #PB_JSON_Number
If JSONMemberKey(JSONValue) = "id"
JSONResult = GetJSONMember(JSONValue, "result")
If JSONResult
User_Event = GetJSONInteger(JSONMemberValue)
Select User_Event
Case #UE_Page_Navigate
UE_Page_Navigate(JSONResult)
Case #UE_Target_SetDiscoverTargets
UE_Target_SetDiscoverTargets(JSONResult)
EndSelect
EndIf
EndIf
Case #PB_JSON_String
If JSONMemberKey(JSONValue) = "method"
JSONParams = GetJSONMember(JSONValue, "params")
If JSONParams
Method_Event$ = GetJSONString(JSONMemberValue)
Select Method_Event$
Case "Target.targetCreated"
ME_Target_TargetCreated(JSONParams)
Case "Target.targetInfoChanged"
ME_Target_TargetInfoChanged(JSONParams)
EndSelect
EndIf
EndIf
EndSelect
EndIf
EndIf
EndIf
FreeJSON(JSONEvent)