from typing import Optional, Any, Dict
from ._DataType import DataType


class Message(object):
    def __init__(self, token, data_type=DataType.empty, data=None, timeout=-1, headers=None):
        # type: (int, int, Optional[Any], int, Optional[Dict[str, str]]) -> None
        self.token = token
        self.data_type = data_type
        self.data = data
        self.timeout = timeout
        self.headers = headers if headers is not None else {}
        self.imp_message = None  # type: Any

    def __eq__(self, o):
        # type: (object) -> bool
        if not isinstance(o, Message):
            return False

        return \
            self.token == o.token \
            and self.data_type == o.data_type \
            and self.data == o.data \
            and self.timeout == o.timeout \
            and self.headers == o.headers

    def __ne__(self, o):
        # type: (object) -> bool
        return not self.__eq__(o)

    def __str__(self):
        return str({
            "token": self.token,
            "data_type": self.data_type,
            "timeout": self.timeout,
            "headers": self.headers
        })
