简体   繁体   English

Google App Engine通道API客户端的无窗口容器

[英]Windowless container for Google App Engine channel API client

I would like to write a commandline tool that receives notifications from Google App Engine's Channel API. 我想编写一个命令行工具来接收来自Google App Engine的Channel API的通知。 This seems to be quite straightforward thanks to open JavaScripts VMs such as v8 and js. 这要归功于开放的JavaScript VM(例如v8和js),这非常简单。 One problem with this approach, though, is that these VMs do not provide standard js objects such as window and document , which the channel API references. 但是,这种方法的问题在于,这些VM不提供通道API引用的标准js对象(例如windowdocument Running such code therefore gives you window/document/.. not found errors. 因此,运行此类代码会给您window/document/.. not found错误。

There seem to be two ways of circumventing this obstacle: 似乎有两种方法可以克服此障碍:

  1. To write a lightweight header in javascript to emulate the behavior of the required objects. 在javascript中编写轻量级标头以模拟所需对象的行为。
  2. To edit Google's javascript (/_ah/channel/jsapi) and eliminate references to such objects. 编辑Google的javascript(/ _ah / channel / jsapi)并消除对此类对象的引用。

Does anyone know if there are existing implementations of these approaches, or know of a better idea? 有谁知道这些方法是否已有实现,或者知道更好的主意? Furthermore, is there a clean, uncompressed version of the channel API client side javascript code available somewhere? 此外,在某处是否有通道API客户端javascript代码的未经压缩的全新版本?

You can't edit the script used by /_ah/channel/jsapi -- it's only used when the channel is running against the dev app server. 您无法编辑/ _ah / channel / jsapi使用的脚本-仅当通道针对dev app服务器运行时才使用。 When running in production, that script redirects to https://talkgadget.google.com/talkgadget/channel.js 在生产环境中运行时,该脚本将重定向到https://talkgadget.google.com/talkgadget/channel.js

So you're left with emulating the required objects, or just using a hidden browser window. 因此,您只需要模拟所需的对象,或者仅使用隐藏的浏览器窗口即可。 I would opt for the latter, since I think emulating all the DOM calls is going to get very difficult very quickly. 我选择后者,因为我认为模拟所有DOM调用将很快变得非常困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM