syncano.models.channels¶
- class PollThread(connection, endpoint, callback, error=None, *args, **kwargs)[source]¶
Bases: threading.Thread
- class Channel(**kwargs)[source]¶
Bases: syncano.models.archetypes.Model
OO wrapper around channels `link http://docs.syncano.io/docs/realtime-communication`_.
Variables: - name – StringField
- type – ChoiceField
- group – IntegerField
- group_permissions – ChoiceField
- other_permissions – ChoiceField
- custom_publish – BooleanField
Note
Channel has two special methods called publish and poll. First one will send message to the channel:
>>> channel = Channel.please.get('instance-name', 'channel-name') >>> channel.publish({"x": 1})
second one will create long polling connection which will listen for messages:
>>> def callback(message=None): ... print message ... return True >>> channel = Channel.please.get('instance-name', 'channel-name') >>> channel.poll(callback=callback)
- TYPE_CHOICES = ({'display_name': 'Default', 'value': 'default'}, {'display_name': 'Separate rooms', 'value': 'separate_rooms'})¶
- PERMISSIONS_CHOICES = ({'display_name': 'None', 'value': 'none'}, {'display_name': 'Subscribe', 'value': 'subscribe'}, {'display_name': 'Publish', 'value': 'publish'})¶
- name = None¶
- type = None¶
- group = None¶
- group_permissions = None¶
- other_permissions = None¶
- custom_publish = None¶
- links = None¶
- DoesNotExist¶
alias of ChannelDoesNotExist
- instance_name = None¶
- pk = None¶
- please¶
- class Message(**kwargs)[source]¶
Bases: syncano.models.archetypes.Model
OO wrapper around channel hisotry `link http://docs.syncano.io/docs/realtime-communication`_.
Variables: - room – StringField
- action – ChoiceField
- author – JSONField
- metadata – JSONField
- payload – JSONField
- created_at – DateTimeField
- ACTION_CHOICES = ({'display_name': 'custom', 'value': 0}, {'display_name': 'create', 'value': 1}, {'display_name': 'update', 'value': 2}, {'display_name': 'delete', 'value': 3})¶
- room = None¶
- action = None¶
- metadata = None¶
- payload = None¶
- created_at = None¶
- DoesNotExist¶
alias of MessageDoesNotExist
- channel_name = None¶
- id = None¶
- instance_name = None¶
- pk = None¶
- please¶