Groovy cometd 客户端 LongPollingTransport.create() 抛出 MissingMethodException
Groovy cometd client LongPollingTransport.create() throws MissingMethodException
我的groovy代码:
import org.cometd.client.BayeuxClient;
import org.cometd.client.transport.ClientTransport;
import org.cometd.client.transport.LongPollingTransport;
import org.eclipse.jetty.client.HttpClient as MyHttpClient
def myurl = "http://192.168.11.170:8080/"
MyHttpClient httpClient = new MyHttpClient()
httpClient.start()
println (httpClient.GET(myurl).getStatus())
BayeuxClient client = new BayeuxClient(myurl, LongPollingTransport.create(null))
client.handshake()
client.waitFor(1000, BayeuxClient.State.CONNECTED)
这里我想做一个handshake
。它只是此处显示的文档示例代码 https://docs.cometd.org/current/apidocs/org/cometd/client/BayeuxClient.html。但我收到如下所示的错误。不知道我做错了什么?
输出:
200
groovy.lang.MissingMethodException: No signature of method: static org.cometd.client.transport.LongPollingTransport.create() is applicable for argument types: (null) values: [null]
Possible solutions: grep(), terminate(), iterator(), accept(java.lang.String), accept(java.lang.String), print(java.lang.Object)
BayeuxClient
的 Javadoc 与 LongPollingTransport
class 完全不同步 - there is no such method as LongPollingTransport.create(arg)
.
相反,您可以尝试使用此 class 的常规构造函数,例如
BayeuxClient client = new BayeuxClient(myurl, new LongPollingTransport([:], httpClient))
第一个参数是选项映射(在此示例中为空),第二个参数是 Jetty 的实例 HttpClient
您导入为 MyHttpClient
。
我的groovy代码:
import org.cometd.client.BayeuxClient;
import org.cometd.client.transport.ClientTransport;
import org.cometd.client.transport.LongPollingTransport;
import org.eclipse.jetty.client.HttpClient as MyHttpClient
def myurl = "http://192.168.11.170:8080/"
MyHttpClient httpClient = new MyHttpClient()
httpClient.start()
println (httpClient.GET(myurl).getStatus())
BayeuxClient client = new BayeuxClient(myurl, LongPollingTransport.create(null))
client.handshake()
client.waitFor(1000, BayeuxClient.State.CONNECTED)
这里我想做一个handshake
。它只是此处显示的文档示例代码 https://docs.cometd.org/current/apidocs/org/cometd/client/BayeuxClient.html。但我收到如下所示的错误。不知道我做错了什么?
输出:
200
groovy.lang.MissingMethodException: No signature of method: static org.cometd.client.transport.LongPollingTransport.create() is applicable for argument types: (null) values: [null]
Possible solutions: grep(), terminate(), iterator(), accept(java.lang.String), accept(java.lang.String), print(java.lang.Object)
BayeuxClient
的 Javadoc 与 LongPollingTransport
class 完全不同步 - there is no such method as LongPollingTransport.create(arg)
.
相反,您可以尝试使用此 class 的常规构造函数,例如
BayeuxClient client = new BayeuxClient(myurl, new LongPollingTransport([:], httpClient))
第一个参数是选项映射(在此示例中为空),第二个参数是 Jetty 的实例 HttpClient
您导入为 MyHttpClient
。