|
-
Aug 28th, 2006, 11:56 AM
#1
Thread Starter
New Member
RaiseEvent and Classes (need expert's help)
Ok, so here i am all happy n stuff, working on a FTP Server in VB.NET.
Feel like I'm in paradise cause I recently switched over from VB6.
Heres the problem.
I have the following Classes
ServerClass
> which contains ListenerClass (private)
> which in turn contains ClientClass (private)
so its like ServerClass.ListenerClass.ClientClass
The server class contains a event, "InternalMessage"
ie. Public Shared Event InternalMessage(ByVal theMsg as String)
(don't worry i shall provide sample code...read on plz )
Now basically I'm developing a windows service, but I'm doing the actual developing as a console application to make everything easy.
so this console application basically creates the "server class"
and simply calls a serverclass.start to start up the whole FTP Server.
However I want the serverclass and its internal classes to be able to report back to the "Mother Application" which can be either a console application or whatever.
SOOOO, BASICALLY whan a remote host connects I want the ClientClass to be able to pass on a message to the Mother Application via what'ever means nessesary.
Heres the sample code.
Module Module1
dim withevents ftp as new serverclass
sub Main()
ftp.startservice
console.readline()
end sub
sub onMessage(ByVal theMessage as String) Handles ftp.InternalMessage
console.writeline(theMessage)
end sub
end Module
that was the mother application
these are the classes
public class ServerClass
Public Shared Event InternalMessage(ByVal msg as string)
public sub StartService()
raiseevent internalmessage("Starting Service")
dim LS as new ListenerClass
LS.Start
end sub
private class ListenerClass
public sub New()
dim client as new ClientClass
end sub
end class
private class ClientClass
public sub New()
'blah blah blah
'CODE NEEDED HERE TO CALL ON THE raiseevent internal message of ServerClass that was defined as FTP by the console application
end class
end class
so basically what im trying to do is, get the ClientClass to invoke the event of a an instance of serverclass. or ie. its Parent Class.
HELP PLEAAASE
Or if you have any other method of transporting messages "upwards" of the object hierarchy please do advise.
(and NO i dont want to pass down a "reporting type" object all the way down each time a new class is created.)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|