【发布时间】:2014-02-05 11:56:15
【问题描述】:
有没有办法使用 WebSocket4Net 进行 Http 身份验证?我想将凭据传递给我的客户。这是我的代码的样子:
public bool Connect(string uri, ICredentials credentials = null)
{
if (this.ws == null)
{
try
{
////this.ws = new WebSocket(uri, string.Empty, WebSocketVersion.None, null, );
this.ws = new WebSocket(uri);
this.ws.Opened += this.OnWebSocketOpen;
this.ws.Closed += this.OnWebSocketClose;
this.ws.Error += this.OnWebSocketFail;
this.ws.MessageReceived += this.OnWebSocketMessage;
try
{
this.ws.Open();
return true;
}
catch (Exception ex)
{
Log.Error("Open web socket failed", ex);
this.ws = null;
}
}
catch (Exception exception)
{
throw new CanNotConnectToDeviceException(new Uri(uri, UriKind.Relative), exception);
}
}
return false;
}
【问题讨论】:
-
这个问题你解决了吗?还是我应该专注于它?
标签: c# http authentication websocket credentials