Giter VIP home page Giter VIP logo

python's People

Contributors

ccraciun avatar dharanad avatar flokx avatar florimond avatar kelindar avatar tanelpuhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python's Issues

Retrieve key generated

I know that's on the documentation as a ToDo, but how can we retrieve the generated key ? Bellow is a sample code, how can we retrieve it following this example?

from emitter import Client

key = "8houiFt2MZ469D0oiBlaibkVcERscGyP"

def onConnect():
    print("Connected!")
    
def onKeygen():
    print("Key generated!")


if __name__ == '__main__':
    emitter = Client()

    emitter.on_connect = onConnect()
    emitter.on_keygen = onKeygen()

    emitter.connect("localhost", 8080, False, 30)
    emitter.keygen(key, "/test/", "rwsl")

    emitter.loop_start()

    while True:
        pass

Django errors

Hi,

I have a problem setting up this client for the Django project. I created a project with Cookiecutter Django (https://github.com/cookiecutter/cookiecutter-django). The project uses ASGI and Docker. I wanted to add an Emitter client but I couldn't find any documentation about how it can be done. Since this library is based on Paho, I tried setups for Paho. I created mqtt.py to handle the client code and initialized it in both asgi.py and url.py. In both scenarios, the Django server halts. I also couldn't be able to connect to my Emitter Server too. (I can connect with plain Python script). How can I make it properly connected?

mqtt.py

from emitter import Client

master_sub_key = "full_authorized_subscription_key"  
master_channel = "/#/" 
emitter_host = "api.emitter.io"
emitter_port = "8080"


def on_connect():
    print("Connected: \n\n")


def on_disconnect():
    print("Disconnected\n\n")
    print("Reconnecting in 1 minute...")
    time.sleep(60)
    emitter.connect(host=emitter_host, port=emitter_port, secure=False)


def on_error(e):
    print(f"Error received: {str(e)}\n\n")


def on_me(me):
    print(f"Information about Me received: {str(me)}\n\n")


def on_subscribe(m, channel):
    print(f"Message received on handler for {channel}: {m.as_string()}\n\n"),


def on_presence(p):
    print(f"Presence message on channel: '{str(p)}'\n\n"),


def on_keygen(kg):
    print(f"Keygen message received: {str(kg)}\n\n")


def on_keyban(kb):
    print(f"Keyban message received: {str(kb)}\n\n")


def on_message(m):
    print(
        f"Message received on default handler, destined to {m.channel}: {m.as_string()}\n\n"
    )


def mqtt_setup():
    emitter = Client()
    emitter.on_connect = on_connect
    emitter.on_disconnect = on_disconnect
    emitter.on_error = on_error
    emitter.on_keygen = on_keygen
    emitter.on_keyban = on_keyban
    emitter.on_me = on_me
    emitter.on_presence = on_presence
    emitter.on_message = on_message

    emitter.connect(host=emitter_host, port=emitter_port, secure=False)
    emitter.subscribe(
       master_sub_key,
       master_channel,
       optional_handler=lambda m: on_subscribe(m, master_channel),
       options={Client.with_last(5)},
       )
    emitter.loop_start()

urls.py

# ****
from .mqtt import mqtt_setup

mqtt_setup()

# ****

what does ".link()" method does and how to subscribe it?

As mentioned in the docs .link() method is used to create 2 char links. As I understand that is a shorthand for channels. There is a .publish_with_lik() method but no .subscribe_with_lik() method. How can I utilize links?

No module named 'subtrie'

Problem

I installed the package version 2.0.0 and get this error when trying using:

image

In version 1.3.0 I can import it or using the source code. The problem is with the package at version 2.0.0

Details

Package version: 2.0.0
SO: Manjaro, Linux
Python version: 3.7.3

Question about wildcard '#'

Hi,

There is one thing that confused me about the source code when I was reading emitter.py and here is the code:

def _format_channel(key, channel, options={}):
        k = key.strip("/")
        c = channel.strip("/")
        o = Client._format_options(options)
        
        formatted = "{key}/{channel}/{options}".format(key=k, channel=c, options=o)
        return formatted

The code here indicates that whatever the channel is, a "/{options}" will be added after it. However, this makes it impossible to use the wildcard '#' since it has to be the last charactor in the topic.

Or is there a special way to use the wildcard '#' in Emitter?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.