'Class module
Sub Class_Globals
Private fx As JFX
Private Async As AsyncStreams
Private mSocket As Socket
Private mID As Int
Private destination As Socket
Private destAsync As AsyncStreams
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(sock As Socket, id As Int, dest As Socket)
mSocket.Initialize("socket")
mSocket = sock
Async.Initialize(mSocket.InputStream, mSocket.OutputStream, "AsyncStream")
mID = id
If dest <> Null Then
destination.Initialize("Destination")
destination = dest
destAsync.Initialize(Null, destination.OutputStream, "DestinationStream")
End If
End Sub
public Sub GetSocket As Socket
Return mSocket
End Sub
Sub AsyncStream_NewData(Buffer() As Byte)
Dim tmpStr As String
tmpStr = BytesToString(Buffer, 0, Buffer.Length, "ASCII")
If destAsync.IsInitialized Then
SocketManager.RaiseEvent(mSocket, tmpStr & " -> " & destination.RemoteAddress)
destAsync.Write(Buffer)
Else
SocketManager.RaiseEvent(mSocket, tmpStr & " -> null")
End If
End Sub