Hiya,
I've got a small problem. I have an interface called "event", which represents a networking event. I have classes implementing this interface. Now, when my server app receives a new event, it checks the class of the event and acts accordingly. This works nicely when the implementing classes are different, but the program can't distinguish two similar classes.
Let's say we have class A and class B which both implement Event interface. I want to check the classes like this:
Event event;
// Get the event from network
A a = event as A;
if(a != null) {
// Message is of type 'A'
}
B b = event as B;
if(b != null) {
// Message is of type 'B'
}
This works nicely, but it can't distinguish the classes (if the classes have similar properties and methods). The code snippet thinks the event is always of type 'A'. How can I make the classes distinct, thus making the server act correctly? I'd like to identify the events bases on the class. I know I could bypass this by adding more information inside the events and check that info, but identifying by class would be a lot neater option. :)