i am starting my road to write a tcp server in b4j
this is the starting server code
i have a question how can i set a client class for each connected client ?
like set username date connected client ip etc.. for each client that connected to server ?
this is the starting server code
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim Server As ServerSocket
Dim AStreams As AsyncStreamsText
Dim Socket1 As Socket
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
Server.Initialize(5251, "Server")
Server.Listen
MainForm.Show
End Sub
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
Log("Connected")
Socket1 = NewSocket
AStreams.Initialize(Me, "AStreams", Socket1.InputStream, Socket1.OutputStream)
Else
Log(LastException.Message)
End If
Server.Listen
End Sub
Public Sub NewData (data As String)
Log(data)
End Sub
Sub AStreams_NewText(Text As String)
NewData(Text)
End Sub
Public Sub SendData (data As String)
AStreams.Write(data)
End Sub
Sub AStreams_Error
Log(LastException.Message)
Log("AStreams_Error")
End Sub
Sub AStreams_Terminated
Log("AStreams_Terminated")
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
i have a question how can i set a client class for each connected client ?
like set username date connected client ip etc.. for each client that connected to server ?