# mediahandler.py - Application entry point
# Holds the TCP server
#
# Copyright 2007 Nokia
# Author: Daniel d'Andrada T. de Carvalho <daniel.carvalho@indt.org.br>
#
# This file is part of mediahandler-skeleton.
#
# mediahandler-skeleton is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# mediahandler-skeleton is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with mediahandler-proxy. If not, see <http://www.gnu.org/licenses/>.

import SocketServer
import sys
from session import Session
import shared
import os

if len(sys.argv) != 2:
    print 'Usage: mediahandler [port]'
    sys.exit(1)

shared.init()

#server host is a tuple ('host', port)
server = SocketServer.ThreadingTCPServer(('localhost', shared.server_port), Session)

while not shared.should_quit:
    server.handle_request()
