red5 0.6rc1支持javascript

      :: Flash :: 2006-11-12 8:18

red5 o.6rc1发布时最吸引目光的莫过于其中支持javascript,ruby,python等

所谓的支持这些语言应该是后台吧,我猜想。如果是,那真太好了。

带着这个疑惑,连忙装上跑一跑

\webapps\oflaDemo\WEB-INF\src\applications中有这个程序的其他三个版本,分别是js,ruby,python。

看看js的代码:

importPackage(Packages.org.red5.server.api);
importPackage(Packages.org.red5.server.api.stream);
importPackage(Packages.org.red5.server.api.stream.support);
importPackage(Packages.org.apache.commons.logging);

importClass(Packages.org.springframework.core.io.Resource);
importClass(Packages.org.red5.server.api.Red5);
importClass(Packages.org.red5.server.api.IScopeHandler);

var IStreamCapableConnection = Packages.org.red5.server.api.stream.IStreamCapableConnection;

function object(o) {
 function Application() {
  this.appScope;
  this.serverStream;
  this.className = 'Application';
 
  this.getClassName = function() {
   return this.className;
  };
  
  appStart: function(app) {
   if (log.isDebugEnabled) {
    print('Javascript appStart');
   }
   this.appScope = app;
   return true;
  };
 
  appConnect: function(conn, params) {
   log.error('Javascript appConnect');
   if (log.isDebugEnabled) {
    print('Javascript appConnect');
   }
   measureBandwidth(conn);
   if (conn == typeof(IStreamCapableConnection)) {
    var streamConn = conn;
    var sbc = new Packages.org.red5.server.api.stream.support.SimpleBandwidthConfigure();
    sbc.setMaxBurst(8388608);
    sbc.setBurst(8388608);
    sbc.setOverallBandwidth(2097152);
    streamConn.setBandwidthConfigure(sbc);
   }
   return this.__proto__.appConnect(conn, params);
  };
  
  appDisconnect: function(conn) {
   if (log.isDebugEnabled) {
    print('Javascript appDisconnect');
   }
   if (this.appScope == conn.getScope() && this.serverStream)  {
    this.serverStream.close();
   }
   return this.__proto__.appDisconnect(conn);
  };  
  
  toString: function(string) {
   return 'Javascript:Application';

  };

 }
 Application.prototype = o;
 return new Application();
}

//if a super class exists in the namespace / bindings
if (supa) {
 if (log.isDebugEnabled) {
  print('New instance of prototype: ' + supa);
 }
 object(supa);
}

在看python的代码:

from org.red5.server.adapter import ApplicationAdapter
from org.red5.server.api.stream import IStreamCapableConnection
from org.red5.server.api.stream.support import SimpleBandwidthConfigure

class Application(ApplicationAdapter):
   
    def appStart(self, app):
        ApplicationAdapter.appStart(self, app)
        print 'Python appStart', app
        self.appScope = app
        return 1

    def appConnect(self, conn, params):
        ApplicationAdapter.appConnect(self, conn, params)
        print 'Python appConnect:', conn, params
        self.measureBandwidth(conn)
        if isinstance(conn, IStreamCapableConnection):
            print 'Python setting bandwidth limits'
            sbc = SimpleBandwidthConfigure()
            sbc.setMaxBurst(8388608)
            sbc.setBurst(8388608)
            sbc.setOverallBandwidth(2097152);
            conn.setBandwidthConfigure(sbc);
       
        return 1

    def toString(self):
        return 'Python:Application'

def getInstance(*args):
    print 'Arguments:', args
    return Application()

感觉js的代码看的比较花眼,不是真的很oo啊

嗯,努力做个demo来看看!

标签集:TAGS:red5
回复Comments() 点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}