我刚刚在Windows应用程序中试用过FireSharp。我可以毫无问题地连接,查询和更新数据。但是,我无法让监听器正常工作。
在OnSync调用创建侦听器之后,objListener = Nothing。没有错误,只是不返回任何值。
*** OBJECT ***
Public Class AlertData
Private new_value As String = Nothing
Public Property NewValue() As String
Get
Return new_value
End Get
Set(ByVal value As String)
new_value = value
End Set
End Property
End Class
*** CONNECTING\LISTENING ***
objConfig = New FirebaseConfig()
With objConfig
.AuthSecret = "<My Secret>"
.BasePath = "<My URL>"
End With
objClient = New FireSharp.FirebaseClient(objConfig)
If objClient IsNot Nothing Then
Dim objListener As EventStreamResponse = Await objClient.OnAsync("alert", Function(s, args, context) {txtUpdate.Text = args.ToString})
End If
*** READING ***
Dim objResult As AlertData
Dim objResponse As FireSharp.Response.FirebaseResponse
Try
objResponse = Await objClient.GetAsync("alert")
objResult = objResponse.ResultAs(Of AlertData)
txtUpdate.Text = objResult.NewValue
Catch ex As Exception
strErrMsg = ex.Message
End Try
*** WRITING ***
Dim objData As AlertData
Dim objResult As AlertData
Dim objResponse As SetResponse
Try
objData = New AlertData()
objData.NewValue = Now.ToString("yyyy-MM-dd hh:mm:ss")
objResponse = Await objClient.SetAsync("alert", objData)
objResult = objResponse.ResultAs(Of AlertData)
Catch ex As Exception
strErrMsg = ex.Message
End Try