# Path: sio/workers/util.py
# def json_dumps(obj, **kwargs):
#     """Python 3 and 2 compatible json.dump."""
#     kwargs.setdefault('cls', CompatibleJSONEncoder)
#     return json.dumps(obj, **kwargs)


from twisted.protocols.basic import NetstringReceiver
from twisted.internet import defer, reactor
from twisted.logger import Logger
from enum import Enum
from sio.workers.util import json_dumps
import six
import json
        )
        # Don't return here - we would get potentially useless
        # 'unhandled error' messages

    def _timeout(self, rid):
        d = self.pendingCalls[rid][0]
        del self.pendingCalls[rid]
        d.errback(TimeoutError())

    def sendMsg(self, msg_type, **kwargs):
        kwargs['type'] = msg_type
        self.sendString(json_dumps(kwargs).encode('utf-8'))

    def call(self, cmd, *args, **kwargs):
        """Call a remote function. Raises RemoteError if something goes wrong
        on the remote end and TimeoutError on timeout.
        Warning: remote tasks can *not* be cancelled and will keep executing
        even if connection is dropped. You should handle this manually.
        """
        if 'timeout' in kwargs:
            timeout = kwargs['timeout']
        else:
            timeout = self.defaultTimeout
        d = defer.Deferred()
        current_id = self.requestID
        self.requestID += 1
        timer = reactor.callLater(timeout, self._timeout, current_id)

        def cb(ignore):
            self.pendingCalls[current_id] = (d, timer)

# Path: sio/workers/util.py
# def json_dumps(obj, **kwargs):
#     """Python 3 and 2 compatible json.dump."""
#     kwargs.setdefault('cls', CompatibleJSONEncoder)
#     return json.dumps(obj, **kwargs)


# Path: sio/protocol/rpc.py
from twisted.protocols.basic import NetstringReceiver
from twisted.internet import defer, reactor
from twisted.logger import Logger
from enum import Enum
from sio.workers.util import json_dumps
import six
import json

        )
        # Don't return here - we would get potentially useless
        # 'unhandled error' messages

    def _timeout(self, rid):
        d = self.pendingCalls[rid][0]
        del self.pendingCalls[rid]
        d.errback(TimeoutError())

    def sendMsg(self, msg_type, **kwargs):
        kwargs['type'] = msg_type
        self.sendString(json_dumps(kwargs).encode('utf-8'))

    def call(self, cmd, *args, **kwargs):
        """Call a remote function. Raises RemoteError if something goes wrong
        on the remote end and TimeoutError on timeout.
        Warning: remote tasks can *not* be cancelled and will keep executing
        even if connection is dropped. You should handle this manually.
        """
        if 'timeout' in kwargs:
            timeout = kwargs['timeout']
        else:
            timeout = self.defaultTimeout
        d = defer.Deferred()
        current_id = self.requestID
        self.requestID += 1
        timer = reactor.callLater(timeout, self._timeout, current_id)

        def cb(ignore):
            self.pendingCalls[current_id] = (d, timer)

            s = json_dumps(