hi all
the application i am creating allows a user to query a game server which used udppackets that will then display the results.
i the query works fine with no problem.
BUT
when i try calling on the result which will then be displayed within my panels it just appears blank
i am kind of lost for words in how to fix it
here is code snippets of what i am doing
calling the results of the packet
displaying within my new loop
THIS IS WHERE THE INFORMATION IS NOT BEING OUTPUTTED
im not sure why i cant return the results what i am looking for within the panels
the panels show but no data is showing
i am trying to display multiple servers in a list i tryed adding everything into 2 subs but it just wont work i think its killing its self when it goes through each server and it overrides the int variables but i am unsure on how to correct this
below is how i initate hte udp packet
BELOW the udp try catch i had the rest of the information to poplate the views but it did not make a difference
which i replaces with "getmainlist" hich starts a new query
the application i am creating allows a user to query a game server which used udppackets that will then display the results.
i the query works fine with no problem.
BUT
when i try calling on the result which will then be displayed within my panels it just appears blank
i am kind of lost for words in how to fix it
here is code snippets of what i am doing
B4X:
Sub Globals
Dim Conv As ByteConverter
Dim Bytes(0) As Byte
' /////// PASS THE RETURNED PACKET TO THESE BELOW VARIABLES ///////
Dim servername As String
Dim passwd As String
Dim racestatus As String
Dim currentplayers As String
Dim totalplayers As String
Dim track As String
Dim wear As String
Dim real As String
Dim length As String
Dim port As String
Dim flags As String
' /////// END ///////
End Sub
calling the results of the packet
B4X:
Sub UDP_PacketArrived (packet As UDPPacket)
Dim msg As String
Dim newbyte() As Byte
msg = BytesToString(packet.Data, packet.Offset, packet.length, "ASCII")
servername = msg.SubString2(20, 45).Trim
' check to see if a password is required on the server
passwd = Byte2toint(packet.Data, 55)
If passwd = 1 Then
passwd = "Required"
Else
passwd = "Not Required"
End If
port = Byte2toint(packet.Data, 52).Trim
track = msg.SubString2(69, 84).Trim
End Sub
displaying within my new loop
THIS IS WHERE THE INFORMATION IS NOT BEING OUTPUTTED
B4X:
Sub getmainlist
CsrServerList1 = SQLServerList.ExecQuery("SELECT * FROM pub_serverlist")
' initilise the scrollview that will cover the entire activity
svcList.Initialize(50)
' the scrollview takes tge whole screen gets added to the activity
Activity.AddView(svcList,0,100dip,100%x,80%y)
' initilise the images
srvOnline.Initialize(File.DirAssets, "flag_green.png")
srvOffline.Initialize(File.DirAssets, "flag_red.png")
' create the panel that holds all other panels
Dim PanelGreen As Panel
' attach panel green to the scrollview and give it a color
PanelGreen = svcList.Panel
PanelGreen.Color = Colors.Green
' the panel that holds each item
Dim itemPanel As Panel
' set the top and the height of the very first item - set to 0 so its at the very top of the scrollview
Dim itemPanelTop, itemPanelHeight As Int
itemPanelTop = 0
itemPanelHeight = 90dip
' the very heart of the sub. Iterate through each row of data and creates each entry wirh labels, text and so forth
For i=0 To CsrServerList1.RowCount - 1
' position 1, 2, 3 and so forth
CsrServerList1.Position = i
' get the ID of each entry as it will be added to the tag od each view (label, image etc)
Dim ID As Int
ID = CsrServerList1.GetInt("id")
' itemPanel Panel that holds each Item
itemPanel.Initialize("itemPanel")
itemPanel.Tag = ID
PanelGreen.AddView(itemPanel,0,itemPanelTop,svcList.Width,itemPanelHeight)
'itemPanel.Color = Colors.DarkGray ' can use a single color
' make the itemPanel Panel into a gradient to hold more that one color
Dim gd1 As GradientDrawable
Dim cols1(2) As Int
gd1.Initialize("TOP_BOTTOM", cols1)
gd1.CornerRadius = 20
itemPanel.Background = gd1
cols1(0) = Colors.LightGray
cols1(1) = Colors.DarkGray
Dim ip As String = servername
' SERVER IP ADDRESS
Dim lblServerName As Label
lblServerName.Initialize("lblServerName")
itemPanel.AddView(lblServerName,80dip,0dip,240dip,40dip)
lblServerName.TextColor = Colors.White
lblServerName.TextSize = 24
lblServerName.Tag = ID
lblServerName.Text = ip
' very important gives the top of the next itempnl as it stacks down the pnlgreen
itemPanelTop = itemPanelTop + itemPanelHeight + 1dip
Log("ItemPnl Top " & itemPanelTop)
Next
' the final height of the green panel is the height of the last item and its top.
PanelGreen.Height = itemPanelTop
' close the cursor to free up resources
CsrServerList1.Close
End Sub
im not sure why i cant return the results what i am looking for within the panels
the panels show but no data is showing
i am trying to display multiple servers in a list i tryed adding everything into 2 subs but it just wont work i think its killing its self when it goes through each server and it overrides the int variables but i am unsure on how to correct this
below is how i initate hte udp packet
BELOW the udp try catch i had the rest of the information to poplate the views but it did not make a difference
which i replaces with "getmainlist" hich starts a new query
B4X:
Sub populatescrollviewlist
CsrServerList = SQLServerList.ExecQuery("SELECT * FROM pub_serverlist")
' the very heart of the sub. Iterate through each row of data and creates each entry wirh labels, text and so forth
For i=0 To CsrServerList.RowCount - 1
' position 1, 2, 3 and so forth
CsrServerList.Position = i
' get the ID of each entry as it will be added to the tag od each view (label, image etc)
Dim ID As Int
ID = CsrServerList.GetInt("id")
' ////////// UDP PACKET START //////////
Dim ip, qportb4 As String
Dim qportaft As Int
ip = CsrServerList.GetString("serverip")
qportb4 = CsrServerList.GetString("queryport")
qportaft = qportb4
Try
Dim packet As UDPPacket
Dim Data() As Byte
Data = "server track arena".GetBytes("ASCII")
packet.Initialize(Data,ip,qportb4)
UdpClient.Send(packet)
Catch
Msgbox("something wnet wrong", "packet error found")
Log(LastException)
End Try
' ////////// UDP PACKET STOP ///////////
getmainlist
Next
CsrServerList.Close
End Sub
Last edited: