所以我们要玩!可以与SocketIO(javascript)客户端通信的应用程序。
到目前为止,我已经尝试过:
使用播放!内置WebSocket并发送与node.js服务器完全相同的字符串。结果根本无法正常工作。我可以在chrome框架选项卡中看到返回的消息,但是当来自nodejs服务器的消息触发onEvent处理程序时,Java实现从不执行此操作。
使用/移植socket.io.play项目。结果与Play相同!websocket版本,服务器获取消息,响应,但是消息不会触发javascript事件处理程序。
第三个Java实现是netty-socketio。我还没有尝试过,但是当我需要在另一个端口上启动而不是使用服务器端口和路由中的构建时,主要概念存在问题。
Java和scala版本都受到欢迎,我可以同时使用。
所以我的问题是:
播放Java控制器返回类型的示例:
public class WebSocketWithCallBack extends WebSocket<String> {
private static List<Out<String>> globalOutList = new ArrayList<>();
@Override
public void onReady(In<String> in, final Out<String> out) {
//Adding the output to the room
globalOutList.add(out);
System.out.println("adding output, " + globalOutList.size());
// For each event received on the socket,
in.onMessage(new F.Callback<String>() {
public void invoke(String event) {
//send event to all outputs
System.out.println("recieved message: ");
System.out.println(event);
for(Out<String> …Run Code Online (Sandbox Code Playgroud) 我不需要在我的项目中使用javascript保留路由,所以我想摆脱生成的类,但如果它甚至不是首先生成的话,它会更容易.
那么有什么选择可以解决这个问题吗?
我在从 Windows Powershell 执行 filename.exe(名称不相关)时遇到问题。filename.exe 可以轻松地从 cmd 执行,因为该文件的路径已添加到 PATH 环境变量中。所以我可以从命令行执行 filename.exe:
filename arg1 arg2
Run Code Online (Sandbox Code Playgroud)
我不知道如何在 Powershell 中执行此操作。
编辑: 我也尝试过同样的方法,但没有成功。我收到以下消息
PS D:\> filename
filename : The term 'filename' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ filename
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (filename:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : …Run Code Online (Sandbox Code Playgroud)