ãã®é±æ«ãé·éç大çºå¸ã®ç¾éº»å°åºã§å ¨æ¥æ¬å¤§å¦å¯¾æé¸æ権ãã¼ãã¬ã¼ã¹ãéå¬ããã¾ããã
ãã®æãUstreamã使ã£ã¦ãã«ããã£ã³ãã«ï¼è¤æ°ã«ã¡ã©ï¼ã§ã®é
ä¿¡ãè¡ãã¾ããã
å±±éã§ã¯ã¤ã¤ã¬ã¹ã®åç·ç¶æ³ã¯é常ã«å¼±ããããï¼å°ç¹ã«åºå®ã®ã«ã¡ã©ãç½®ãã¦ãå°åºå
ã«å°å
¥ããã¦ããã±ã¼ãã«ã¤ã³ã¿ã¼ããã網ãçµç±ãã¦ãåç»ãä¸ãã¾ããã
ãã¼ãã¬ã¼ã¹ã®ãããªå ´åã ã¨ãã ãããéå£ã¯åºã¾ã£ã¦ãã¾ãã®ã§ã次è¦ã¦ããããããã£ã³ãã«ã¨ããã®ã¯ã»ã¼æ±ºã¾ã£ã¦ãã¾ãã
ããã§ãå»å¹´ã¯ï¼ãã£ã³ãã«ãã«ãç»é¢ã§è¦ã¦ããã£ãã®ã§ãããä»å¹´ã¯é
ä¿¡å´ãä»è¦ã¦æ¬²ãããã£ã³ãã«ãé¸æåºæ¥ãã·ã¹ãã ãä½ã£ã¦æä¾ãã¾ããã
ã¤ã¾ãããããã¬ãã®ã¹ãã¼ãä¸ç¶ã§ãã«ãã«ã¡ã©ãåãæ¿ããªããæ¾éãã¦ãããããªãããã«è¿ãäºãåºæ¥ãããã§ãã
ãã®ã·ã¹ãã ã«ã¯ãUcastationãã¨ããååãä»ãã¾ããã
ä¸è¨URLãããè¦ã«æ¥ã人ãè¦ã¦ãããã¼ã¸ã¨ã管çç¨ã®ãã¢ãã¼ã¸ãå©ç¨ã§ãã¾ãã
管çå´ç»é¢ããã¯ãå·¦ä¸ã®ã©ã¸ãªãã¿ã³ã§ãã£ã³ãã«ã®åãæ¿ãã¨ãã¬ã¼ã¹ç¶æ³ãªã©ã®åç¥ç¨æ²ç¤ºæ¿ã使ãã¾ãã
å®éã«åãã試ããã¨ãåºæ¥ã¾ãã®ã§ãã¦ã¤ã³ãã¦ãï¼ã¤éãã¦ç®¡çç¨ãã¼ã¸ã®æä½ã§åç»ãåãæ¿ããã®ã試ãã¦ã¿ã¦ãã ããã
Ucastation view page
http://miasa.info:2011/
Ucastation admin page
http://miasa.info:2011/admin.html
ãããUstreamæ¬å®¶ã§åºæ¥ã¦ãè¯ããããªæ©è½ã ã¨æãã®ã§ãããå®éã«ã¯åºæ¥ã¾ããã
ã§ã¯ã©ããã£ã¦å®ç¾ãã¦ãããã¨ããã¨ãnode.jsã¨socket.ioãå©ç¨ãã¦ãview pageãè¦ã¦ãã人ã«ä»è¦ã¦æ¬²ãããã£ã³ãã«åãéã£ã¦ããããã©ã¦ã¶å´ã§ãã®ãã£ã³ãã«ã®åç»ã表示ãç´ããã¨ãã¦ããã®ã§ãã
ã³ã¢ã¨ãªãé¨åã®ã½ã¼ã¹ã¯ãããªæãã§ããå®éã®ã½ã¼ã¹ãããã£ã³ãã«å¤æ´ã®æ©è½ããã¿ã ããæç²ãã¦ã¾ãã
ãucastation.jsã
var conf = { port : 20011, admin_password : '***password***' }; var express = require( 'express' ); var app = express.createServer(); var io = require( 'socket.io' ).listen( app ); app.configure( function() { app.use( express.static( __dirname + '/public' ) ); }); app.listen( conf.port ); var channel; // viewã¨ã®éä¿¡ var view = io.of( '/view' ).on( 'connection', function( client ) { // æ¥ç¶æãã¯ã©ã¤ã¢ã³ãã«ç¾å¨ã®ãã£ã³ãã«ãéä¿¡ if ( channel ) { client.emit( 'channel', channel ); } // åæå¦ç client.on( 'disconnect', function() { console.log( "disconnect" ); }); }); // adminã¨ã®éä¿¡ var admin = io.of( '/admin' ).on( 'connection', function( client ) { var login = false; // 管çè ã®ãã°ã¤ã³ãªã¯ã¨ã¹ã client.on( 'admin login', function( password, fn ) { if ( password == conf.admin_password ) { console.log( "admin login success." ); login = true; fn( "OK admin login" ); } else { console.log( "warning! admin password failer." ); login = false; } }); // ãã£ã³ãã«å¤æ´ client.on( 'admin channel', function( ch, fn ) { if ( login == true ) { console.log( "admin channel" ); channel = ch; view.emit( 'channel', channel ); fn( "OK admin channel" ); } else { console.log( "warning! not login." ); } }); // åæå¦ç client.on( 'disconnect', function() { console.log( "disconnect" ); }); }); console.log( "Server started." );
ãadmin.jsã
var port = 20011; var password = '***password***'; var socket = io.connect( "/admin", { port: port } ); socket.emit( 'admin login', password, function( reply ) { if ( reply == "OK admin login" ) { $("#condition").html( "<div class='alert-message success'>管çè èªè¨¼æå</div>" ); } }); socket.on( 'connect', function() { $("#condition").html( "<div class='alert-message success'>æ¥ç¶æå</div>" ); }); socket.on( 'disconnect', function() { $("#condition").html( "<div class='alert-message error'>åæ</div>" ); }); function sendChannel( channel ) { $("#condition").html( "<div class='alert-message info'>ãã£ã³ãã«éä¿¡ä¸...</div>" ); socket.emit( 'admin channel', channel, function( reply ) { if ( reply == "OK admin channel" ) { $("#condition").html( "<div class='alert-message success'>ãã£ã³ãã«éä¿¡æå</div>" ); } }); }
ãview.jsã
// WebSocketã§ã®éä¿¡é¨å var port = 20011; var socket = io.connect( "/view", { port: port } ); socket.on( 'connect', function() { }); socket.on( 'channel', function( channel ) { Player.play( channel, 'ust_main' ); });
ãããã端æã£ã¦ããããUstã®åç»ã表示ããjavascriptã¨ããå¿
è¦ã§ããããããªã«çãã³ã¼ãã§ãããªãã¨ãæ¸ãã¡ããã¾ãã
Coffeeã¹ã¯ãªããã®æ¸å¼ã§æ¸ãããããã«çãã2/3ãããã§æ¸ãã®ã§ã¯ãªãã§ãããããnodeï¼websocketãããï¼
ã¡ãªã¿ã«githubã¯ãããå°æ±ãã½ã¼ã¹ã§ããããªã«ãåèã«ãªãã°ã
https://github.com/stealthinu/ucastation
Ucastationã¯ãã¾ã ã¾ã αçã¨ããæãã§ä¸æãåããªãç¶æ³ãããããã ã£ãããã¾ãããä»å¾ãããããæ©è½ã¢ãããèãã¦ããã¨ããã§ãã