本文整理匯總了Python中socketio.server.SocketIOServer方法的典型用法代碼示例。如果您正苦於以下問題:Python server.SocketIOServer方法的具體用法?Python server.SocketIOServer怎麽用?Python server.SocketIOServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類socketio.server
的用法示例。
在下文中一共展示了server.SocketIOServer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: from socketio import server [as 別名]
# 或者: from socketio.server import SocketIOServer [as 別名]
def handle(self, addrport='', *args, **options):
if not addrport:
self.addr = ''
self.port = DEFAULT_PORT
else:
m = match(naiveip_re, addrport)
if m is None:
raise CommandError('"%s" is not a valid port number '
'or address:port pair.' % addrport)
self.addr, _, _, _, self.port = m.groups()
environ['DJANGO_SOCKETIO_PORT'] = str(self.port)
if options.get('use_psyco'):
try:
from psycogreen.gevent import patch_psycopg
except ImportError:
raise CommandError(
'Could not patch psycopg. '
'Is psycogreen installed?')
patch_psycopg()
if options.get('use_reloader'):
start_new_thread(reload_watcher, ())
try:
bind = (self.addr, int(self.port))
print 'SocketIOServer running on %s:%s\n\n' % bind
handler = self.get_handler(*args, **options)
server = SocketIOServer(
bind, handler, resource='socket.io', policy_server=True
)
server.serve_forever()
except KeyboardInterrupt:
for key, sock in six.iteritems(server.sockets):
sock.kill(detach=True)
server.stop()
if RELOAD:
print 'Reloading...\n\n'
restart_with_reloader()
示例2: run
# 需要導入模塊: from socketio import server [as 別名]
# 或者: from socketio.server import SocketIOServer [as 別名]
def run(self,handler):
from socketio import server
address = (self.host, self.port)
server.SocketIOServer(address, handler, **self.options).serve_forever()
示例3: run
# 需要導入模塊: from socketio import server [as 別名]
# 或者: from socketio.server import SocketIOServer [as 別名]
def run(self, handler):
from socketio import server
address = (self.host, self.port)
server.SocketIOServer(address, handler, **self.options).serve_forever()