Ejemplo n.º 1
0
    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()

        # Make the port available here for the path:
        #   socketio_tags.socketio ->
        #   socketio_scripts.html ->
        #   io.Socket JS constructor
        # allowing the port to be set as the client-side default there.
        environ["DJANGO_SOCKETIO_PORT"] = str(self.port)
        sdjango.autodiscover()
        start_new_thread(reload_watcher, ())
        try:
            bind = (self.addr, int(self.port))
            print
            print "SocketIOServer running on %s:%s" % bind
            print
            handler = self.get_handler(*args, **options)
            server = SocketIOServer(bind, handler, resource="socket.io", policy_server=True)
            server.serve_forever()
        except KeyboardInterrupt:
            if RELOAD:
                server.stop()
                print "Reloading..."
                restart_with_reloader()
            else:
                raise
Ejemplo n.º 2
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.core.urlresolvers import reverse_lazy

from socketio import sdjango
sdjango.autodiscover()

urlpatterns = patterns(
    '',
    url(r'^$', 'tracker_project.views.home', name='home'),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^accounts/', include('django.contrib.auth.urls')),
    url(
        r'^logout/$',
        'django.contrib.auth.views.logout',
        {'next_page': reverse_lazy('home')},
        name='logout'
    ),
    url(r'^tracker/', include('tracker.urls', 'tracker')),
    url(r'^socket\.io', include(sdjango.urls))
)
Ejemplo n.º 3
0
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from django.views.static import serve
from socketio import sdjango

from menu.views import MenuView
from order.views import (
    KitchenView,
    LoginView,
    complete_order,
    logout,
    redirect_authenticated,
    update_orders,
)

sdjango.autodiscover()

urlpatterns = [
    url(r"^socket\.io", include(sdjango.urls)),
    url(r"^admin/", admin.site.urls),
    url(r"^$", csrf_exempt(MenuView.as_view()), name="menu"),
    url(r"^login/?$",
        redirect_authenticated(LoginView.as_view()),
        name="login"),
    url(r"^logout/?$", logout, name="logout"),
    url(r"^kitchen/?$", login_required(KitchenView.as_view()), name="kitchen"),
    url(r"^kitchen/update/?$", update_orders, name="update_orders"),
    url(r"^kitchen/completeorder/?$", complete_order, name="complete_order"),
]

# Add media folder to urls when DEBUG = True