我正在使用C#和WebSocket4Net库构建一个安全的WebSockets客户端.我希望我的所有连接都通过标准代理进行代理.
这个lib使用SuperSocket.ClientEngine.Common.IProxyConnector指定websocket连接的代理,但我不确定我应该如何实现它.
有没有人在这个图书馆工作,可以提供一些建议吗?
我正在尝试使用Xamarin和WebSocket4Net进行简单的测试,但是在"正在进行操作"的Open()上失败了.示例代码如下:
using Xamarin.Forms;
using WebSocket4Net;
using System;
using SuperSocket.ClientEngine;
namespace SocketTest
{
public partial class SocketTest : ContentPage
{
private WebSocket websocket;
public SocketTest()
{
InitializeComponent();
}
void Handle_Clicked(object sender, System.EventArgs e)
{
websocket = new WebSocket("ws://echo.websocket.org/");
websocket.Opened += Websocket_Opened;
websocket.Error += Websocket_Error;
websocket.Closed += Websocket_Closed;
websocket.MessageReceived += Websocket_MessageReceived;
websocket.Open();
}
private void Websocket_Error(object sender, ErrorEventArgs e)
{
Console.WriteLine(e.Exception.Message);
}
private void Websocket_MessageReceived(object sender, EventArgs e)
{
Console.WriteLine(e.ToString());
}
private void Websocket_Closed(object sender, EventArgs e)
{
Console.WriteLine(e.ToString());
}
private void …Run Code Online (Sandbox Code Playgroud) 我正在使用websocket4net在 C# 中创建 WebSocket 客户端并与服务器通信。
我能够发送数据,但无法接收服务器发回的回复。根本Client_MessageReceived没有被触发。不过我可以在 WireShark 中看到回复。
我正在使用的代码如下:
class CommandRPC
{
public String jsonrpc;
public String method;
public Parameter @params;
public String id;
}
class Parameter
{
public String cmd;
}
class Program
{
static WebSocket Client;
static CommandRPC command;
static void Main(string[] args)
{
Client = new WebSocket("ws://10.131.35.32/DIAG");
Client.Opened += new EventHandler(Client_Opened);
Client.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(Client_Error);
Client.Closed += new EventHandler(Client_Closed);
Client.MessageReceived += new EventHandler<MessageReceivedEventArgs>(Client_MessageReceived);
Client.DataReceived += new EventHandler<DataReceivedEventArgs>(Client_DataReceived);
command = new CommandRPC();
command.jsonrpc = …Run Code Online (Sandbox Code Playgroud) 我需要从C#windows窗体代码连接基于Node.js的WebSocket
节点模块使用https://github.com/Automattic/socket.io
我正在使用superwebsocket和WebSocket4Net
using SuperSocket.Common;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Config;
using SuperSocket.SocketBase.Logging;
using SuperWebSocket;
using SuperWebSocket.SubProtocol;
using WebSocket4Net;
......
......
WebSocket webSocketClient = new WebSocket("ws://localhost:8080/");
webSocketClient.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(webSocketClient_Error);
webSocketClient.AllowUnstrustedCertificate = true;
webSocketClient.Opened += new EventHandler(webSocketClient_Opened);
webSocketClient.Closed += new EventHandler(webSocketClient_Closed);
webSocketClient.MessageReceived += new EventHandler<MessageReceivedEventArgs>(webSocketClient_MessageReceived);
webSocketClient.Open();
Run Code Online (Sandbox Code Playgroud)
但只有webSocketClient_Error回调始终触发,任何人都可以帮忙吗?
我有一个 C# 桌面应用程序和一个 C# 服务器控制台应用程序。
C# 桌面客户端应用程序使用 WebSocket4Net,而我的 C# 服务器应用程序使用 Fleck。
我假设它使用 TCP 协议是否正确。如果是这样,我可以让它使用UDP协议吗?
我问这个的原因是因为我读取 TCP 比 UDP 慢,因为 TCP 确保数据包的顺序。
我从这篇文章中读到了这个: