diff -r 000000000000 -r 27e83a8f68d7 gmyth-stream/server/main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/main.py Tue Apr 03 16:42:04 2007 +0100 @@ -0,0 +1,81 @@ +#!/usr/bin/python + +import os +import lib +import sys +import ConfigParser + +config = ConfigParser.ConfigParser() +config.read("stream.conf") + +media_plugin = config.get("Media", "engine") +exec("from plugins.media.%s import *" % media_plugin) + +media = Media(config) + +comm_plugin = config.get("Comm", "engine") +exec("from plugins.comm.%s import *" % comm_plugin) + +# Start Our Server: +server = Server(config) + +lib.log("Starting GMyth-Stream server") + +while (server.finish == 0): + con, client = server.getRequest() + + while True: + msg = server.getMsg(1024).strip() + + if not msg: break + + lib.log("Received %s from: %s" % (msg, client) ) + + if (msg == "SETUP"): + setup = server.getMsg(1024).strip().split(" ") + size = len(setup) + options = [] + + if ( size < 10 ): + server.sendMsg(lib.log("Wrong SETUP command from: %s" % client[0])) + + else: + + if ( size > 10 ): + i = 10 + while (i < size): + options.append(setup[i]) + i += 1 + + ret = media.setup(setup[0], setup[1], setup[2], \ + setup[3], setup[4], setup[5], + setup[6], setup[7], setup[8], + setup[9], options) + + if (ret == 0): + server.Ack("SETUP") + else: + server.sendMsg(lib.log(ret)) + + + elif (msg == "PLAY"): + media.play() + server.Ack("PLAY") + + elif (msg == "STOP"): + media.stop() + server.Ack("STOP") + + elif (msg == "CLOSE"): + server.finish = 1 + media.stop() + server.Ack("CLOSE") + break + + lib.log("Closing connection with %s" % client[0]) + server.disconnect_client(con) + +server.stop() +del(server) +lib.log("Server stopped. Closing...") +