本文整理匯總了Python中channel.Channel.init_event方法的典型用法代碼示例。如果您正苦於以下問題:Python Channel.init_event方法的具體用法?Python Channel.init_event怎麽用?Python Channel.init_event使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類channel.Channel
的用法示例。
在下文中一共展示了Channel.init_event方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: connect
# 需要導入模塊: from channel import Channel [as 別名]
# 或者: from channel.Channel import init_event [as 別名]
def connect(self, conn):
'''
Nawiazywanie polaczenia, inicjalizujace eventy
'''
#jesli uzytkonik zalogowany id -> pk usera
#if conn.request.user.is_authenticated():
# conn.id = conn.request.user.pk
conn.id = self.id_gen.next()
user_id = conn.get_user_id()
logger.debug("New connection; user %s; path %s; conn_id %s " % (user_id,
conn.request.path_info, conn.id))
if user_id not in self.users:
self.users[user_id] = {}
#tworzymy kanaly dla wspieranych eventow i doklejamy zdarzenia
for event in conn.events:
if active_events.has_key(event):
#niezalogowani uzytkownicy moga odbierac tylko broadcasty
if active_events[event].is_init_event():
Channel.init_event(conn, event, shared=self.shared)
if self.history.has_key(event):
self.history[event].send_history(conn)
if not (active_events[event].is_broadcast_event() or
conn.request.user.is_authenticated()):
continue
#XXX: nadmiarowe, w konstruktorze wszystkie kanaly sa inicjalizowane
if not self.channels.has_key(event):
logger.error('Brak kanalu %s, to niepowinno miec miejsca' % event)
self.channels[event] = Channel(event, tracker=self,
history=self.history.get(event, None))
if not self.users[user_id].has_key(event):
self.users[user_id][event] = True
self.channels[event].new_connection(conn)