Naime, pokusavam sa telefona da se konektujem na desktop racunar. Konekcija prodje kako treba, server je prihvati i sa telefona uspem da posaljem poruku serveru. Medjutim do problema dolazi kada posaljem poruku sa severa na telefon. Dobijem poruku neocekivana greska.
Ono sto mi predstavlja problem je to sto ne znam u kom trenutku dolazi do nje da bih je mogao otkloniti. Naime kada program stavim u debug mod, on jednostavno ne primeti nista. Jednostavno cim primim poruku sa servera, ne znam ni u kojoj liniji, program se jednostavno ugasi.
Moze li neko da pomogne?
Code:
'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 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.
Dim 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("Layout1")
Activity.LoadLayout ("Form1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click 'konektuj se
Socket1.Initialize ("Socket1")
Socket1.Connect ("12.104.31.143",8800,2000)
End Sub
Sub Button2_Click 'posalji poruku
If AStreams.IsInitialized = False Then Return
If EditText1.Text.Length > 0 Then
Dim buffer() As Byte
buffer = EditText1.Text.GetBytes("UTF8")
AStreams.Write(buffer)
End If
End Sub
Sub Socket1_Connected (Successful As Boolean)
ToastMessageShow("Konektovan", False)
AStreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "AStreams")
End Sub
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
ToastMessageShow(msg, False)
Log(msg)
End Sub
'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 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.
Dim 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("Layout1")
Activity.LoadLayout ("Form1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click 'konektuj se
Socket1.Initialize ("Socket1")
Socket1.Connect ("12.104.31.143",8800,2000)
End Sub
Sub Button2_Click 'posalji poruku
If AStreams.IsInitialized = False Then Return
If EditText1.Text.Length > 0 Then
Dim buffer() As Byte
buffer = EditText1.Text.GetBytes("UTF8")
AStreams.Write(buffer)
End If
End Sub
Sub Socket1_Connected (Successful As Boolean)
ToastMessageShow("Konektovan", False)
AStreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "AStreams")
End Sub
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
ToastMessageShow(msg, False)
Log(msg)
End Sub
Po logici stvari greska bi trebala da se desi u Sub AStreams_NewData jer tu prima podatke ali ako ovde stavim STOP nikada ne dodje do izvrsenja te linije.