入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

normal用户同一时间只能有一个登录session,如何实现多个登录?

创建时间:2011-12-29 投稿人: 浏览次数:152

声明:本博客只代表作者本人,不代表作者所在公司和组织等。如因此采用本博客内容造成的损失和不便,本博客概不负责。如需相应service请联系对应厂商


1,下载client

      

2,编写脚本

      脚本A(foreverToken.pl)

-----------------

#!/usr/bin/perl -w
use BuildForge::Services;

        $conn = new BuildForge::Services::Connection("localhost");
        $token = $conn->authUser("yq","qq");
        print "token: $token ";
        #$conn->authToken($token);
 
        # Getting existing projects
        $project = BuildForge::Services::DBO::Project->findByName($conn, "proj1");

        # Getter / setter functions
        $id = $project->getProjectId();
        $name = $project->getName();
        $class = $project->getBuildClass();
        $env = $project->getEnvironmentId();

        print "Name: $name ";
        print "ID: $id ";
        print "Class: $class ";
        print "Env ID: $env ";
        
        #wait for a very long, the other script can use the same session.
        my $verbose = 99999999;
        my $idx = 0;
        while ($idx<$verbose) {
         sleep 20;
         $idx =$idx+1;
         warn "index: $idx ";
       }
                
        $conn->logout;
        $conn->close;

       脚本B(shareToken.pl

-------------------------

#!/usr/bin/perl -w
use BuildForge::Services;

        $conn = new BuildForge::Services::Connection("localhost");
        #$token = $conn->authUser("yq","qq");

        #get the token after the scriptA is executed
        $conn->authToken("77baef380c571000ca2b83f44d314d31");
 
        # Getting existing projects
        $project = BuildForge::Services::DBO::Project->findByName($conn, "proj2share");

        # Getter / setter functions
        $id = $project->getProjectId();
        $name = $project->getName();
        $class = $project->getBuildClass();
        $env = $project->getEnvironmentId();

        print "Name: $name ";
        print "ID: $id ";
        print "Class: $class ";
        print "Env ID: $env ";
        
        
        #don"t logout or close, for myabe other scripts are using this session at the same time
         print "exit";

3, 执行脚本

    如图1所示的目录结构

     perl -I "c:\autofvt bf-serviceslib" foreverToken.pl

     得到输出token,后修改shareToken.pl,然后在新的cmd窗口执行shareToken.pl

     perl -I "c:\autofvt bf-serviceslib" shareToken.pl


声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。