Bonjour à tous
En créant une Socket de communication j'arrive à communiquer avec un autre support à partir d'une activity. Lorsque je change d'activity je n'arrive plus à communiquer. Je souhaite envoyer des données et en recevoir avec plusieurs activity. J'ai essayer de fermer la socket pour la réouvrir mais sa ne marche pas Voici un exemple:
activity1 :
Sub Process_Globals
Dim AStreams1 As AsyncStreams
Dim Socket1 As Socket
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Socket2.Close
Socket1.Initialize("Socket1")
Socket1.Connect("192.168.0.1",24,1500)' IP, Port, Timeout
End If
End Sub
Sub Socket1_Connected(Connected As Boolean)As Boolean
If Connected = True Then7AStreams1.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "astreams1")
End If
End Sub
End Sub
activity2:
Sub Process_Globals
Dim AStreams2 As AsyncStreams
Dim Socket2 As Socket
End Sub
Sub Globals
Dim label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Socket1.Close
Socket2.Initialize("Socket2")
Socket2.Connect("192.168.0.1",24,1500)' IP, Port, Timeout
End If
End Sub
Sub Socket2_Connected(Connected As Boolean)As Boolean
If Connected = True Then
AStreams2.InitializePrefix(Socket2.InputStream, False, Socket2.OutputStream, "astreams2")
End If
End Sub
Sub Btn_Tare_Click
Dim buffer() As Byte
label1.Text="SWP"
buffer = label1.Text.GetBytes("UTF8")
AStreams2.Write(buffer)
End Sub
Merci
En créant une Socket de communication j'arrive à communiquer avec un autre support à partir d'une activity. Lorsque je change d'activity je n'arrive plus à communiquer. Je souhaite envoyer des données et en recevoir avec plusieurs activity. J'ai essayer de fermer la socket pour la réouvrir mais sa ne marche pas Voici un exemple:
activity1 :
Sub Process_Globals
Dim AStreams1 As AsyncStreams
Dim Socket1 As Socket
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Socket2.Close
Socket1.Initialize("Socket1")
Socket1.Connect("192.168.0.1",24,1500)' IP, Port, Timeout
End If
End Sub
Sub Socket1_Connected(Connected As Boolean)As Boolean
If Connected = True Then7AStreams1.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "astreams1")
End If
End Sub
End Sub
activity2:
Sub Process_Globals
Dim AStreams2 As AsyncStreams
Dim Socket2 As Socket
End Sub
Sub Globals
Dim label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Socket1.Close
Socket2.Initialize("Socket2")
Socket2.Connect("192.168.0.1",24,1500)' IP, Port, Timeout
End If
End Sub
Sub Socket2_Connected(Connected As Boolean)As Boolean
If Connected = True Then
AStreams2.InitializePrefix(Socket2.InputStream, False, Socket2.OutputStream, "astreams2")
End If
End Sub
Sub Btn_Tare_Click
Dim buffer() As Byte
label1.Text="SWP"
buffer = label1.Text.GetBytes("UTF8")
AStreams2.Write(buffer)
End Sub
Merci