in WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/WebSocket.cs [49:89]
private async Task ConnectInternalAsync(
Uri endpoint)
{
this.websocket = new MessageWebSocket();
this.websocket.Control.MessageType = SocketMessageType.Utf8;
this.websocket.MessageReceived += this.MessageReceived;
this.websocket.Closed += (senderSocket, args) =>
{
if (this.websocket != null)
{
this.websocket.Dispose();
this.websocket = null;
this.IsListeningForMessages = false;
}
};
if (this.deviceConnection.Credentials != null)
{
PasswordCredential cred = new PasswordCredential();
cred.UserName = this.deviceConnection.Credentials.UserName;
cred.Password = this.deviceConnection.Credentials.Password;
this.websocket.Control.ServerCredential = cred;
}
//Origin address must be especially cooked to pass through all Device Portal checks
string OriginAddress = this.deviceConnection.Connection.Scheme + "://" + this.deviceConnection.Connection.Host;
if ((this.deviceConnection.Connection.Scheme == "http" && this.deviceConnection.Connection.Port != 80) ||
(this.deviceConnection.Connection.Scheme == "https" && this.deviceConnection.Connection.Port != 443))
{
OriginAddress += ":" + this.deviceConnection.Connection.Port;
}
this.websocket.SetRequestHeader("Origin", OriginAddress);
await this.websocket.ConnectAsync(endpoint);
this.IsConnected = true;
}