![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | client_id_from_token |
def | validate_token_and_extract_client_id |
def | get_channel_messages |
def | has_channel_messages |
def | pop_first_message |
def | clear_channel_messages |
def | add_connect_event |
def | disconnect_channel_event |
def | add_disconnect_event |
def | connect_channel |
def | connect_and_pop_first_message |
![]() | |
def | __init__ |
def | CreateRPC |
def | MakeSyncCall |
def | SetError |
Static Public Attributes | |
THREADSAFE = True | |
int | CHANNEL_TIMEOUT_SECONDS = 2 |
string | XMPP_PUBLIC_IP = '0.1.0.10' |
int | CHANNEL_TOKEN_DEFAULT_DURATION = 120 |
string | CHANNEL_TOKEN_IDENTIFIER = 'channel' |
![]() | |
THREADSAFE = False | |
Additional Inherited Members | |
![]() | |
request_data | |
Python only channel service stub. This stub does not use a browser channel to push messages to a client. Instead it queues messages internally.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.__init__ | ( | self, | |
log = logging.debug , |
|||
service_name = 'channel' , |
|||
time_func = time.time , |
|||
request_data = None |
|||
) |
Initializer. Args: log: A logger, used for dependency injection. service_name: Service name expected for all calls. time_func: function to get the current time in seconds. request_data: A request_info.RequestInfo instance. If None, a request_info._LocalRequestInfo instance will be used.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.add_connect_event | ( | self, | |
client_id | |||
) |
Tell the application that the client has connected.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.add_disconnect_event | ( | self, | |
client_id | |||
) |
Add an event to notify the app if a client has disconnected. Args: client_id: A client ID used for a particular channel.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.clear_channel_messages | ( | self, | |
token | |||
) |
Clears all messages from the channel. Args: token: A string representing the channel. Note that this is the token returned by CreateChannel, not the client id.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.client_id_from_token | ( | self, | |
token | |||
) |
Returns the client id from a given token. Args: token: A string representing an instance of a client connection to a client id, returned by CreateChannel. Returns: A string representing the client id used to create this token, or None if this token is incorrectly formed and doesn't map to a client id.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.connect_and_pop_first_message | ( | self, | |
token | |||
) |
Atomically performs a connect_channel and a pop_first_message. This is designed to be called after the channel has already been connected, so that it refreshes the channel's timeout, and retrieves a message, in a single atomic operation. Args: token: A string representing the channel. Note that this is the token returned by CreateChannel, not the client id. Returns: The first message in the queue (a string), or None if no messages. Raises: InvalidTokenError: The token is syntactically invalid. TokenTimedOutError: The token expired or does not exist.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.connect_channel | ( | self, | |
token | |||
) |
Marks the channel identified by the token (token) as connected. If the channel has not yet been connected, this triggers a connection event to let the application know that the channel has been connected to. If the channel has already been connected, this refreshes the channel's timeout so that it will not disconnect. This should be done at regular intervals to avoid automatic disconnection. Args: token: A string representing the channel. Note that this is the token returned by CreateChannel, not the client id. Raises: InvalidTokenError: The token is syntactically invalid. TokenTimedOutError: The token expired or does not exist.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.disconnect_channel_event | ( | self, | |
client_id | |||
) |
Removes the channel from the list of connected channels.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.get_channel_messages | ( | self, | |
token | |||
) |
Returns the pending messages for a given channel. Args: token: A string representing the channel. Note that this is the token returned by CreateChannel, not the client id. Returns: List of messages, or None if the channel doesn't exist. The messages are strings.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.has_channel_messages | ( | self, | |
token | |||
) |
Checks to see if the given channel has any pending messages. Args: token: A string representing the channel. Note that this is the token returned by CreateChannel, not the client id. Returns: True if the channel exists and has pending messages.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.pop_first_message | ( | self, | |
token | |||
) |
Returns and clears the first message from the message queue. Args: token: A string representing the channel. Note that this is the token returned by CreateChannel, not the client id. Returns: The first message in the queue (a string), or None if no messages.
def google.appengine.api.channel.channel_service_stub.ChannelServiceStub.validate_token_and_extract_client_id | ( | self, | |
token | |||
) |
Ensures token is well-formed and hasn't expired, and extracts client_id. Args: token: a token returned by CreateChannel. Returns: A client_id, which is the value passed to CreateChannel. Raises: InvalidTokenError: The token is syntactically invalid. TokenTimedOutError: The token expired or does not exist.