Ejemplo n.º 1
0
import json
import logging
import threading
from threading import Timer
import jsonpickle
from jsonpickle.pickler import Pickler
from ws4py.client.threadedclient import WebSocketClient
from wshubsapi import utils

utils.setSerializerDateTimeHandler()


class WSSimpleObject(object):
    def __setattr__(self, key, value):
        return super(WSSimpleObject, self).__setattr__(key, value)


class WSReturnObject:
    class WSCallbacks:
        def __init__(self, onSuccess=None, onError=None):
            self.onSuccess = onSuccess
            self.onError = onError

    def done(self, onSuccess, onError=None):
        pass


class GenericServer(object):
    __messageID = 0
    __messageLock = threading.RLock()
Ejemplo n.º 2
0
import json
import logging
import threading
from threading import Timer
import jsonpickle
from jsonpickle.pickler import Pickler
from ws4py.client.threadedclient import WebSocketClient
from wshubsapi import utils

utils.setSerializerDateTimeHandler()

class WSSimpleObject(object):
    def __setattr__(self, key, value):
        return super(WSSimpleObject, self).__setattr__(key, value)

class WSReturnObject:
    class WSCallbacks:
        def __init__(self, onSuccess=None, onError=None):
            self.onSuccess = onSuccess
            self.onError = onError

    def done(self, onSuccess, onError=None):
        pass

class GenericServer(object):
    __messageID = 0
    __messageLock = threading.RLock()

    def __init__(self, wsClient, hubName, pickler):
        """
        :type wsClient: WSHubsAPIClient
Ejemplo n.º 3
0
import json
import logging
import sys
import inspect
import threading
from datetime import datetime
import jsonpickle
from jsonpickle.pickler import Pickler

from wshubsapi.ValidateStrings import getUnicode
from wshubsapi.utils import WSMessagesReceivedQueue, setSerializerDateTimeHandler

log = logging.getLogger(__name__)
__author__ = "Jorge Garcia Irazabal"

setSerializerDateTimeHandler()


class CommProtocol(object):
    def __init__(self, messageReceivedThreadPoolSize=20, unprovidedIdTemplate="UNPROVIDED__%d"):
        self.lock = threading.Lock()
        self.availableUnprovidedIds = list()
        self.connections = dict()
        self.unprovidedIdTemplate = unprovidedIdTemplate
        self.lastProvidedId = 0
        self.messageReceivedThreadPoolSize = messageReceivedThreadPoolSize
        self.wsMessageReceivedQueue = WSMessagesReceivedQueue(
            messageReceivedThreadPoolSize
        )  # todo: make dynamic queue size
        self.wsMessageReceivedQueue.startThreads()
Ejemplo n.º 4
0
 def setUp(self):
     self.commHandler = CommHandler()
     utils.setSerializerDateTimeHandler()