Skip to content
This repository has been archived by the owner on Feb 11, 2019. It is now read-only.

Commit

Permalink
handle_outbound_message tested, a couple of lines in StackClient move…
Browse files Browse the repository at this point in the history
…d from start_client to __init__ as they are not needed in the deferToThread and it made testing easier
  • Loading branch information
annasborysova committed Jun 26, 2015
1 parent c47ac09 commit 8bcc595
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions vxyowsup/whatsapp.py
Expand Up @@ -8,15 +8,8 @@

from yowsup.layers.network import YowNetworkLayer

from yowsup.common import YowConstants
from yowsup.layers import YowLayerEvent
from yowsup.stacks import YowStack, YowStackBuilder
from yowsup import env

import sys
import argparse
import yowsup
import logging
from yowsup.stacks import YowStackBuilder

from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
from yowsup.layers.protocol_messages.protocolentities import TextMessageProtocolEntity
Expand All @@ -37,6 +30,7 @@ class WhatsAppTransportConfig(Transport.CONFIG_CLASS):


class WhatsAppClientDone(Exception):

""" Signal that the Yowsup client is done. """


Expand Down Expand Up @@ -87,14 +81,14 @@ class StackClient(object):

def __init__(self, credentials):
self.CREDENTIALS = credentials

def client_start(self):
self.stack = YowStackBuilder.getDefaultStack(
layer=EchoLayer, media=False)
self.stack.setCredentials(self.CREDENTIALS)
self.network_layer = self.stack.getLayer(0)
self.echo_layer = self.stack.getLayer(-1)

def client_start(self):

self.stack.broadcastEvent(YowLayerEvent(
YowNetworkLayer.EVENT_STATE_CONNECT))

Expand All @@ -117,6 +111,7 @@ def _kill():
def send_to_stack(self, text, to_address):
def send():
self.echo_layer.send_to_human(text, to_address)
print('in stack_client', text, to_address)
self.stack.execDetached(send)


Expand All @@ -125,7 +120,7 @@ class EchoLayer(YowInterfaceLayer):
def send_to_human(self, text, to_address):
message = TextMessageProtocolEntity(text, to=to_address)
self.toLower(message)
print(text, to_address)
# print('in echo_layer', text, to_address)

@ProtocolEntityCallback("message")
def onMessage(self, messageProtocolEntity):
Expand Down

0 comments on commit 8bcc595

Please sign in to comment.