简体   繁体   中英

Using WebSockets to communicate between Java and C# desktop applications?

I am interested in deploying a server to GoDaddy as a C# web application, then have desktop clients developed in C# and Java be able to subscribe/publish to the server using WebSockets (RFC 6455).

WebSocket supported libraries I am looking at are XSockets.Net and SignalR .

I am not able to find anything on using XSockets.Net (not to be confused with XSocket.org) in Java. I understand that XSockets targets MS .Net framework and Mono environments. However, looking at SignalR, there is also SignalA which is a Java based SignalR client for Android.

Thinking-out-loud... I understand there are many WebSocket libraries for Java, which suggests the idea that if I am able to publish a message (using WebSocket) from a Java application to a server, then I should be able to read it and processes it in C#, since WebSocket protocol is a standard.

Thus far, I believe a SignalR solution will satisfy my requirement to allow C# & Java applications to talk on the Web, but due to transport requirments of SignalR, my communication will not utilize WebSockets. Reading through SignalR requirements, to get WebSockets transport activated I must use Windows8+ with .Net Framework for 4.5+. GoDaddy does not use Windows8 for windows hosting, and even if it did, then all my clients must also use Windows8, which is not a guarentee.

So the question is: How can I get C# & Java desktop clients to talk on the web via WebSockets, othan than using SignalR and XSockets.Net?

Any help is very much appreciated!

I will now look into deploying a C# XSockets.NET Server and have a C# XSockets.NET client and a Java JWebSocket client since both JWebSockets and XSockets support the WebSocket RFC6455 protocol. 我现在将研究部署C#XSockets.NET服务器,并具有C#XSockets.NET客户端和Java JWebSocket客户端,因为JWebSockets和XSockets均支持WebSocket RFC6455协议。 I will post my findings here and close this question if that was a successful effort.

You can implement a RFC6455 client in any language and use XSockets. However do note that XSockets uses a publish/subscribe pattern that you will have to implement as well to take benefit of the platform.

The upside is that you actually wont have to implement RFC6455 since you can implement a custom (non websocket protocol) and use that when communicating from desktop (or anything else). Since everything in XSockets is a plugin you can add custom protocols and still communicate with client talking RFC6455 since XSockets will offer cross-protocol communication.

So the thing you have to implement is actually only the publish/subscribe functionality in the java client. There are probably not any Java clients out there that implements the IXSocketClient interface today, and we focused on Mono instead of Java when covering multi-platform support.

We will help you out in any way we can if you decide to write your own java implementation.

Note: as of the next version (not far away) it will be very easy to implement your custom protocol and connect from any device talking TCP/IP

In my humble opinion, you have misunderstood some things.

XSockets and SignalR are libraries which are totally oriented to a specific platform , .NET . They both wrap the functionality of WebSockets , a platform independent standard, to ease its use. This does not by anyway mean that you could use XSocket, or SignalR libraries in all platforms .

I suppose that creating a java client for XSockets or SignalR would be an overkill and would lead you to heavily depend on a 3rd party library. In your situation, I would go on with using WebSockets directly on my server side. Then I would use a library handling the WebSockets standard for each client, which could be different for each client development platform. Therefore, you would depend on one universal standard and you would minimize dependencies on 3rd party libraries.

Hope I helped!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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