'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Serversocket1 As ServerSocket
Dim Socket1 As Socket
Dim Timer1 As Timer
Dim input1 As InputStream
Dim output1 As OutputStream
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Button1 As Button
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
Button1.Text = "Test"
Listview1.Clear
If FirstTime Then
Timer1.Initialize("Timer1", 200)
End If
If ServerSocket1.IsInitialized = False Then
ServerSocket1.Initialize(6832, "ServerSocket1")
End If
ToastMessageShow("Meine IP : " & ServerSocket1.GetMyIP, True)
End Sub
Sub ServerSocket1_NewConnection(Successfull As Boolean, NewSocket As Socket)
If Successfull Then
Socket1 = NewSocket
Timer1.Enabled = True
Input1 = Socket1.InputStream
ToastMessageShow("Connected !", True)
Else
Msgbox(LastException.Message, "Error connecting !")
End If
ServerSocket1.Listen
End Sub
Sub Activity_Resume
ServerSocket1.Listen
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
Timer1.Enabled = False
Socket1.Close
ServerSocket1.Close
End If
End Sub
Sub Button1_Click
End Sub
Sub Timer1_Tick
If Input1.BytesAvailable > 0 Then
Timer1.Enabled = False
Dim Buffer(100) As Byte
Dim raf As RandomAccessFile
Dim text As String
raf.Initialize3(Buffer, True)
Input1.ReadBytes(Buffer, 0, 100)
text = BytesToString(Buffer, 0, 100, "UTF-8")
Listview1.AddSingleLine(text)
End If
End Sub