Raising Events

G

Guest

I'm new to event processing in vs 2005 - what I'm trying to achieve is
broadly a network simulation of two workstations sending packets to each
other .

I have defined a class 'Workstation' and I was hoping to define events where
in instance A (or workstation) I could raise an event 'Send' (which takes in
the destination instance B (or workstation) and the Packet to send). The
event would then trigger a 'Receive' event in instance B to receive the
packet.

Public Class Workstation

Public Event SendPacket(ByVal Destination As Workstation, ByVal
SentPacket As Packet)
Public Event ReceivePacket(ByVal Source As Workstation, ByVal
ReceivePacket As Packet)

Public Sub Send(ByVal Destination As Workstation, ByVal SentPacket As
Packet) Handles Me.SendPacket
' send packet to Destination
End Sub

Public Sub Receive(ByVal Source As Workstation, ByVal SentPacket As
Packet) Handles Me.ReceivePacket
' process packet (pick packet to return)
' send packet to Source
End Sub

What I would like to do is raise the ReceivePacket event in the Destination
Workstation but the editor is not letting me add a statement along the lines
of RaiseEvent Destination.ReceivePacket()

any help in this area of two instances 'sending messages' between them would
be much appreciated.

TIA
Rob
 
G

Guest

What I would like to do is raise the ReceivePacket event in the
Destination Workstation but the editor is not letting me add a
statement along the lines of RaiseEvent Destination.ReceivePacket()

any help in this area of two instances 'sending messages' between them
would be much appreciated.

You're raising a SendPacket event right?

Thus on the other end, it's still a SendPacket event - not a ReceivePacket
event.

To make the event name make sense on both sends, perhaps choose a generic
event name such as "PacketData" or "ProcessPacket".
 
R

Rob

Thanks for your reply - I was thinking more along the lines of

Instance A is my 'client' an instance of my Workstation class
Instance B is my 'target' an instance of my Workstation class

1) Instance A Raises a Send Event (passing in Instance B as the
destination and a 'packet' to send as parameters)
2) The Send event raises a Receive Event for Instance B (passing in
'Me' as the Source workstation and the 'packet')
3) The Receive event in Instance B 'receives' the Instance A
workstation and the packet (as a parameter), processes the packet and
determines the response packet
4) Instance B Raises a Send Event (passing in Instance A as the
destination and a packet to send)

Action 1 and 4 are of course the same.

Is it a case of passing in the 'address' of the Instance B receive
event into the Instance A send event in action 1 - so action 2 can
raise that event?

tia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top