Ejemplo n.º 1
0
 mysql.executeSql(sql,param,function(err,vals){
     if (err) {
         throw err;
     }
     if(vals) {
         if(vals.length>0){
             var rtmpUrl="",flvUrl="",m3u8Url="";
             for(var i=0; i < vals.length; i++) {
                 var url=vals[i].url;
                 if(url.indexOf("rtmp")===0){
                     rtmpUrl=url;
                     console.log('rtmp:'+url);
                 }else if(url.lastIndexOf(".flv")==(url.length-4)){
                     flvUrl=url;
                     console.log('flv:'+url);
                 }else if(url.lastIndexOf(".m3u8")==(url.length-5)){
                     m3u8Url=url;
                     console.log('m3u8:'+url);
                 }
             }
             //var url=vals[0].url;
             var author=vals[0].author;
             var vs_id=vals[0].vs_id;
             var hashed_id=vals[0].hashed_id;
             var state=vals[0].state;
             var size=vals[0].size;
             var opaque = '{"player_user":"******","hashed_id":"'+hashed_id+'","recordUser":"******"}';
             var rtpmInit="rtmp_publisher.connect('rtmp://"+config.uri_rtmp+":1934/live','"+author+"', '"+user.id+"', '"+config.SERVICE_CODE+"', null, '"+opaque+"');";
             res.render(page,{
                 title:'远程指导',
                 hashed_id:hashed_id,
                 rtmpUrl:rtmpUrl,
                 flvUrl:flvUrl,
                 m3u8Url:m3u8Url,
                 state:state,
                 deviceSN:deviceSN,
                 vs_id:vs_id,
                 author:author,
                 rtpmInit:rtpmInit,
                 user:req.session.user,
                 size:size,
                 success:req.flash('success').toString(),
                 error:req.flash('error').toString()
             });
         }else{
             req.flash('error', '当前设备无可看直播或您无权观看此次直播');
             return res.redirect('/mylives');
         }
     }
 });
Ejemplo n.º 2
0
  lib.getListPageUrl = function (pageId, pagination) {
    var listPage  = pagination.listPage;
    var url       = '';
    var urlFormat = pagination.url || 'page/:id/';

    if (!fs.existsSync(listPage)) {
      return grunt.fail.fatal('No `options.pagination.listPage` found at ' + listPage);
    }

    // If the pageSrc option is used, generate list pages relative to options.pageSrc
    // Otherwise, generate list pages relative to the root of the destination folder
    if (options.pageSrc) {
      if (listPage.indexOf(options.pageSrc + '/') !== -1) {
        url += listPage.slice(options.pageSrc.length + 1);
      } else {
        return grunt.fail.fatal('The `options.pagination.listPage` must be within the options.pageSrc directory.');
      }
    }

    // The root list page is either the template file's location relative to options.pageSrc
    // or a blank url for the site root
    if (pageId === 0) {
      if (options.pageSrc) {
        url = url.replace(path.extname(listPage), '.html');
      } else {
        url = '';
      }

    // Every other list page's url is generated using the pagination.url property and is either generated
    // relative to the folder that contains the listPage or relative to the root of the site
    } else {
      if (urlFormat.indexOf(':id') === -1) {
        return grunt.fail.fatal('The `options.pagination.url` must include an \':id\' variable which is replaced by the list page\'s identifier.');
      }
      if (options.pageSrc) {
        url = url.replace(path.basename(listPage), urlFormat.replace(':id', pageId));
      } else {
        url += urlFormat.replace(':id', pageId);
      }
    }

    // Remove unnecessary trailing index.html from urls
    if (url.indexOf('index.html') !== -1 &&
        url.lastIndexOf('index.html') === url.length - 'index.html'.length) {
      url = url.slice(0, - 'index.html'.length);
    }

    return url;
  };
Ejemplo n.º 3
0
	server.on("message", function(msg, rinfo) {
		console.log("Cache request: " + msg + " from " + rinfo.address + ":" + rinfo.port);
		var message = msg.toString();
		var arr = message.split(' ');
		console.log(arr);
		var ttl_second, urls;
		ttl_second = arr[1];
		var urlList = [];
		for (var i = 2; i < arr.length; i ++) {
			var url = arr[i];
			if (url.lastIndexOf("http://", 0) == 0) {
			} else {
				url = "http://" + url;
				//continue;
			}
			getURLCache(url, ttl_second);
		}
	});
Ejemplo n.º 4
0
 , shortname: (function (){
   var url = n.find('a[rel="bookmark"]').attr('href')
   var u = url.slice(url.lastIndexOf('/', url.length - 2) + 1)
   return u.slice(0, u.length - 1)
 })()