#Region Project Attributes
#MainFormWidth: 790
#MainFormHeight: 545
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Table As TableView
Private server As ServerSocket
Dim connectionId As Int = 0
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
MainForm.Show
Table.SetColumns(Array As String("Connection ID", "Remote IP","Last Incoming ASCII Message"))
server.Initialize(5005, "server")
server.Listen
End Sub
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
Dim astream As AsyncStreams
astream.InitializePrefix(NewSocket.InputStream, False, NewSocket.OutputStream, "astream")
Dim row(3) As Object
row(0) = connectionId
row(1) = NewSocket.RemoteAddress
row(2) = ""
Table.Items.Add(row)
connectionId = connectionId + 1
Else
Log(LastException)
End If
server.Listen
End Sub
Sub astream_NewData (Buffer() As Byte)
' Log("received: " & DateTime.GetSecond(DateTime.Now))
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Dim selected As Int = table.SelectedRow
If selected = -1 Then Return
Dim row() As Object = table.SelectedRowValues
Dim lbl As Label = row(1)
lbl.Text = msg
End Sub