Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Server As ServerSocket
Dim Socket1 As Socket
Dim AStreams As AsyncStreams
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.
Private Button1 As Button
Private Button2 As Button
Private EditText1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Main2")
If FirstTime Then
Server.Initialize(5555, "Server")
Server.Listen
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button2_Click
End Sub
Sub Button1_Click
Socket1.Initialize("Socket1")
Socket1.Connect("192.168.1.2", 5555, 5000)
End Sub
Sub Socket1_Connected(Connected As Boolean)As Boolean
If Connected = True Then
ToastMessageShow("Connected",True)
Else
ToastMessageShow("Error",True)
End If
End Sub
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
If Successful Then
Socket1 = NewSocket
AStreams.write(Array As Byte(0x16, 0x08, 0x00, 0x00, 0x00, 0x00, 0xE3, 0x2C))
ToastMessageShow("Connesso-OK",True)
End If
Server.Listen
End Sub
Sub AStreams_NewData (Buffer() As Byte)
Dim a As Byte
a = AStreams.StreamReceived
EditText1.Text = a
End Sub