Esempio n. 1
0
    def __init__(self,
                 hostport,
                 metric,
                 tags,
                 startTime,
                 endTime,
                 connect_timeout=WebSocketClient.DEFAULT_CONNECT_TIMEOUT,
                 request_timeout=WebSocketClient.DEFAULT_REQUEST_TIMEOUT,
                 client_cert=None,
                 client_key=None,
                 ca_certs=None,
                 validate_cert=False):

        self.metric = metric
        self.tags = tags
        self.startTime = startTime
        self.endTime = endTime
        self.subscriptionId = random.randint(1000000000, 9999999999)
        WebSocketClient.__init__(self,
                                 hostport,
                                 '/websocket', {'metric': metric},
                                 connect_timeout,
                                 request_timeout,
                                 client_cert=client_cert,
                                 client_key=client_key,
                                 ca_certs=ca_certs,
                                 validate_cert=validate_cert)
Esempio n. 2
0
    def __init__(self, hostport, metric, tags, startTime, endTime, connect_timeout=WebSocketClient.DEFAULT_CONNECT_TIMEOUT,
                 request_timeout=WebSocketClient.DEFAULT_REQUEST_TIMEOUT):

        self.metric = metric
        self.tags = tags
        self.startTime = startTime
        self.endTime = endTime
        self.subscriptionId = random.randint(1000000000, 9999999999)
        WebSocketClient.__init__(self, hostport, connect_timeout, request_timeout)
Esempio n. 3
0
    def __init__(self, hostport, metric, tags, startTime, endTime, connect_timeout=WebSocketClient.DEFAULT_CONNECT_TIMEOUT,
                 request_timeout=WebSocketClient.DEFAULT_REQUEST_TIMEOUT):

        self.metric = metric
        self.tags = tags
        self.startTime = startTime
        self.endTime = endTime
        self.subscriptionId = random.randint(1000000000, 9999999999)
        WebSocketClient.__init__(self, hostport, connect_timeout, request_timeout)
    def __init__(self, hostport, metric, tags, startTime, endTime, connect_timeout=WebSocketClient.DEFAULT_CONNECT_TIMEOUT,
                 request_timeout=WebSocketClient.DEFAULT_REQUEST_TIMEOUT, client_cert=None, client_key=None, ca_certs=None, validate_cert=False):

        self.metric = metric
        self.tags = tags
        self.startTime = startTime
        self.endTime = endTime
        self.subscriptionId = random.randint(1000000000, 9999999999)
        WebSocketClient.__init__(self, hostport, '/websocket', {'metric' : metric}, connect_timeout, request_timeout,
                                 client_cert=client_cert, client_key=client_key, ca_certs=ca_certs, validate_cert=validate_cert)
Esempio n. 5
0
    def __init__(self,
                 hostport,
                 subscriptionId,
                 metric,
                 startTime,
                 endTime,
                 connect_timeout=WebSocketClient.DEFAULT_CONNECT_TIMEOUT,
                 request_timeout=WebSocketClient.DEFAULT_REQUEST_TIMEOUT):

        self.metric = metric
        self.startTime = startTime
        self.endTime = endTime
        self.subscriptionId = subscriptionId
        WebSocketClient.__init__(self, hostport, connect_timeout,
                                 request_timeout)
class TestWebSocketClient(object):

    def setup_class(self):
        self.sock = WebSocketClient()
        self.ws = self.sock.connect(WEBSOCKET_URL)

    def test_connect(self):
        self.sock.connect(WEBSOCKET_URL)

    def test_gettimeout(self):
        pass

    def test_settimeout(self):
        pass

    def test_getsubprotocol(self):
        pass

    def test_getstatus(self):
        pass

    def test_getheaders(self):
        pass

    def test_send(self):
        self.sock.send(self.ws, 'Hello, world')

    def test_send_binary(self):
        pass

    def test_ping(self):
        pass

    def test_pong(self):
        pass

    def test_recv(self):
        self.sock.send(self.ws, 'Hello, world')
        data = self.sock.recv(self.ws)
        assert data == 'Hello, world'

    def test_recv_data(self):
        pass

    def test_send_close(self):
        pass
 def handle(self):
     log.info("new client " + str(self.client_address))
     WebSocketClient(self)
Esempio n. 8
0
from argparse import Namespace
from websocket import create_connection
sys.path.append('./bean')
sys.path.append('./utils')
from Credential import Credential
from MD5Util import MD5Util
from WebSocketClient import WebSocketClient

if __name__ == "__main__":
    file_object = open('credential.json')
    try:
        credential = file_object.read()
    finally:
        file_object.close()

    credential = json.loads(credential, object_hook=lambda d: Namespace(**d))
    if credential is None:
        print("login username (phone number) is required")
    else:
        print("your phone number is %s, password is %s" %
              (credential.phoneNumber, credential.password))
        if credential.password is not None:
            md5Util = MD5Util()
            credential.password = md5Util.MD5Encode(credential.password)
        ws = create_connection(credential.host)
        websocketClient = WebSocketClient(credential)
        websocketClient.onOpen(ws)
        while 1:
            result = ws.recv()
            websocketClient.onMessage(result)
 def setup_class(self):
     self.sock = WebSocketClient()
     self.ws = self.sock.connect(WEBSOCKET_URL)