某互联网(特大型)公司游戏元数据管理系统前端开发技术

本人于去年十月份开始接收游戏元数据管理系统的开发,下面就把使用的技术总结一下:

由于元数据数据库比较多,链接频繁会影响效率,所以我们使用了facebook开源的Thrift,服务端使用C++,客户端链接使用python和php,由于我主要做php,下面是Thrift的php客户端入口文件:

<?php
#Thrift Lib Path Root
$GLOBALS['THRIFT_ROOT']=$_SERVER['DOCUMENT_ROOT']."/application/Thrift/lib";

#Class Namespace Turn Loader
require_once( $GLOBALS['THRIFT_ROOT'] . '/Thrift/ClassLoader/ThriftClassLoader.php' );

use Thrift\ClassLoader\ThriftClassLoader;
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift',  $GLOBALS['THRIFT_ROOT']);
$loader->register();

#All Include
require_once( $GLOBALS['THRIFT_ROOT'] . '/Thrift/Transport/TSocket.php' ); 
require_once( $GLOBALS['THRIFT_ROOT'] . '/Thrift/Transport/TFramedTransport.php' ); 
require_once( $GLOBALS['THRIFT_ROOT'] . '/Thrift/Protocol/TBinaryProtocol.php' ); 
require_once( $GLOBALS['THRIFT_ROOT'] . '/Thrift/Exception/TException.php' ); 
error_reporting(E_ALL);

use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TSocket;
use Thrift\Transport\TFramedTransport;
use Thrift\Exception\TException;
use tdw_res\interity_19;
#Our Self Include 
require_once( 'lib/Thrift/tdw_res/TdwInterityService.php' );
require_once( 'lib/Thrift/tdw_res/Types.php' );
class Thrift{
	private $host;
	private $prot;
	
	private $socket;
	private $transport;
	private $protocol;
	private $client;
	//method
	public function __construct($host='10.**.**.**',$port=9099){
		$this->host=$host;
		$this->port=$port;
		$this->client=$this->connect($this->host,$this->port);
	}
	//建立连接
	public function connect($host, $port){
		$this->socket = new TSocket($host, $port);
		$this->transport = new TFramedTransport($this->socket);
		$this->protocol = new TBinaryProtocol($this->transport);
		$this->client = new tdw_res\interity_19\TdwInterityServiceClient($this->protocol);
		$this->transport->open();
		return $this->client;
	}
	//关闭连接
	public function close(){
		$this->transport->close();
	}
	//操作一
	public function exec_query($db_node,$sql){
		try{
			$db_node=$db_node;
			$sql=$sql;
			$result=$this->client->exec_query($db_node,$sql);
			$this->close();
			return $result;
		}catch(TException $io){
			return 'error:'.$io;
		}
	}
	//添加、更新、删除操作
	public function exec_update($db_node,$sql){
		try{
			$db_node=$db_node;
			$sql=$sql;
			$result=$this->client->exec_query($db_node,$sql);
			$this->close();
			return $result;
		}catch(TException $io){
			return 'error:'.$io;
		}
	}
	//测试
	public function test(){
		return "test";
	}
}

?>
上面是在程序中需要包含的文件,使用了服务端自动生成的php客户端类库文件,使用了大量的命名空间,由于我对这理解的不够深刻,暂时先写到这里,我有空会继续补充的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值