在javascript客户端中的节俭传输 [英] Thrift transport in javascript client

查看:109
本文介绍了在javascript客户端中的节俭传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的Thrift服务器构建一个javascript客户端。服务器已启动并运行,我可以使用PHP客户端调用服务器。我只是无法弄清楚javascript客户端。

I'm trying to build a javascript client for my Thrift server. The server is up and running and I can get calls to the server working with a PHP client. I just can't figure out the javascript client.

特别是,实例化运输让我感到困惑。 http://thrift.apache.org/tutorial/js/ 上的教程显示:

In particular, instantiating the transport baffles me. The tutorial at http://thrift.apache.org/tutorial/js/ shows:

function calc() {
    var transport = new Thrift.Transport("/thrift/service/tutorial/");
    var protocol  = new Thrift.Protocol(transport);
    var client    = new CalculatorClient(protocol);

当我这样做时,我在/ var / www / thrift / service /上获得了一个http 404教程/

When I do this, I get an http 404 on "/var/www/thrift/service/tutorial/"

我发现了一两个其他使用的例子

I've found one or two other examples that use

var transport = new Thrift.Transport("/service");

但这也给了我404.

But that gives me a 404 as well.

我从来没有看到过我应该在javascript中传递给Transport的构造函数的解释。在我的PHP代码中,我创建了一个套接字,然后将其传递给Transport的构造函数。但是,javascript抱怨Thrift.Socket()不是构造函数。

I've never seen an explanation of what I'm supposed to pass to the constructor of Transport in javascript. In my PHP code, I create a socket and then pass that to the constructor of the Transport. However, javascript complains that Thrift.Socket() isn't a constructor.

http://thrift.apache.org/tutorial/js/ 并不是非常有用。它说:

The tutorial at http://thrift.apache.org/tutorial/js/ isn't terribly helpful. It says:


使用Thrift文件的第一件事是设置你的
传输协议。目前,它只支持AJAX,并且随后是

The first thing for using the Thrift files is setting up your Transport protocol. At this time, it only supports AJAX and is as follows:

var transport = new Thrift.Transport("/thrift/service/tutorial/");


没有描述传递给构造函数的路径应该是什么。

There's no description of what that path passed to the constructor should be.

我迷失了。我在javascript中传递给Transport构造函数的是什么?

I'm lost on this. What do I pass to the Transport constructor in javascript?

推荐答案

要使用Javascript客户端,您需要一个HTTP Thrift服务器(例如一个指出的yiding)。您还需要使用 TJSONProtocol

To use a Javascript client you need a HTTP Thrift server (e.g. the one pointed out by yiding). You also need to use TJSONProtocol.

如何使Thrift Java服务器与Thrift Javascript客户端一起工作的文件分散在整个来源。我在这里一起困惑: https://github.com/LukeOwncloud/ThriftJavaJavascriptDemo

The files how to make a Thrift Java server work with an Thrift Javascript client are scattered throughout the source. I puzzled them together here: https://github.com/LukeOwncloud/ThriftJavaJavascriptDemo

这篇关于在javascript客户端中的节俭传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆