Public Sub setItemLS(ws As WebSocket, key As String, value As String)
Dim js As String = $"localStorage.setItem("${key}", "${value}");"$
ws.Eval(js,Null)
End Sub
Public Sub getItemLS(ws As WebSocket, key As String) As String
Dim js As String = $"return localStorage.getItem("${key}");"$
Dim f As Future = ws.EvalWithResult(js,Null)
Return f.Value
End Sub
Public Sub removeItemLS(ws As WebSocket, key As String) As Boolean
Try
Dim js As String = $"localStorage.removeItem("${key}");"$
ws.Eval(js,Null)
Return True
Catch
Log(LastException)
Return False
End Try
End Sub
Public Sub itemExistsLS(ws As WebSocket, key As String) As Boolean
Dim js As String = $"return localStorage.getItem("${key}");"$
Dim f As Future = ws.EvalWithResult(js,Null)
Return f.Value <> Null
End Sub
Public Sub getAllItemsLS(ws As WebSocket) As Map
Dim js As String = $"return localStorage;"$
Dim f As Future = ws.EvalWithResult(js,Null)
Return f.Value
End Sub
Public Sub removeAllLS(ws As WebSocket) As Boolean
Try
Dim m As Map = getAllItemsLS(ws)
For Each key As String In m.Keys
removeItemLS(ws,key)
Next
Return True
Catch
Log(LastException)
Return False
End Try
End Sub