在omnet ++中,handleMessage可以处理cMessage以外的任何类吗?

时间:2017-04-29 03:16:43

标签: omnet++

我想将MyPacket类型的变量传递给handleMessage,它会给出错误。

    public override bool Equals(object obj)
    {
        if (obj.GetType() != typeof(CompareClass))
            return false;

        if (this.compare1 == ((CompareClass)obj).compare1 && this.compare2 == ((CompareClass)obj).compare2)
            return true ;
        else
            return false;
    }

    // oversimplified, this link is more appropriate
    // http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode
    public override int GetHashCode()
    {
        return (this.compare1.GetHashCode() + this.compare2.GetHashCode()) * 11 + 2;
    }

1 个答案:

答案 0 :(得分:2)

您的MyPacket将转换为C {{{{{{{{{{{{}} {{}}。 MyPacket继承自cPacket,因此会由cPacket处理。但是,在cMessage中,您必须识别并投射数据包,例如:

handleMessage