Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5509a96b
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5509a96b
编写于
5月 21, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add BrowserWebSocketFactory
上级
5a97b520
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
96 addition
and
2 deletion
+96
-2
src/vs/platform/remote/browser/browserWebSocketFactory.ts
src/vs/platform/remote/browser/browserWebSocketFactory.ts
+89
-0
src/vs/workbench/services/remote/browser/remoteAgentServiceImpl.ts
...rkbench/services/remote/browser/remoteAgentServiceImpl.ts
+7
-2
未找到文件。
src/vs/platform/remote/browser/browserWebSocketFactory.ts
0 → 100644
浏览文件 @
5509a96b
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IWebSocketFactory
,
IConnectCallback
}
from
'
vs/platform/remote/common/remoteAgentConnection
'
;
import
{
ISocket
}
from
'
vs/base/parts/ipc/common/ipc.net
'
;
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
class
BrowserSocket
implements
ISocket
{
public
readonly
socket
:
WebSocket
;
constructor
(
socket
:
WebSocket
)
{
this
.
socket
=
socket
;
}
public
dispose
():
void
{
this
.
socket
.
close
();
}
public
onData
(
_listener
:
(
e
:
VSBuffer
)
=>
void
):
IDisposable
{
const
fileReader
=
new
FileReader
();
const
queue
:
Blob
[]
=
[];
let
isReading
=
false
;
fileReader
.
onload
=
function
(
event
)
{
isReading
=
false
;
const
buff
=
<
ArrayBuffer
>
(
<
any
>
event
.
target
).
result
;
try
{
_listener
(
VSBuffer
.
wrap
(
new
Uint8Array
(
buff
)));
}
catch
(
err
)
{
onUnexpectedError
(
err
);
}
if
(
queue
.
length
>
0
)
{
enqueue
(
queue
.
shift
()
!
);
}
};
const
enqueue
=
(
blob
:
Blob
)
=>
{
if
(
isReading
)
{
queue
.
push
(
blob
);
return
;
}
isReading
=
true
;
fileReader
.
readAsArrayBuffer
(
blob
);
};
const
listener
=
(
e
:
MessageEvent
)
=>
{
enqueue
(
<
Blob
>
e
.
data
);
};
this
.
socket
.
addEventListener
(
'
message
'
,
listener
);
return
{
dispose
:
()
=>
this
.
socket
.
removeEventListener
(
'
message
'
,
listener
)
};
}
public
onClose
(
listener
:
()
=>
void
):
IDisposable
{
this
.
socket
.
addEventListener
(
'
close
'
,
listener
);
return
{
dispose
:
()
=>
this
.
socket
.
removeEventListener
(
'
close
'
,
listener
)
};
}
public
onEnd
(
listener
:
()
=>
void
):
IDisposable
{
return
Disposable
.
None
;
}
public
write
(
buffer
:
VSBuffer
):
void
{
this
.
socket
.
send
(
buffer
.
buffer
);
}
public
end
():
void
{
this
.
socket
.
close
();
}
}
export
const
browserWebSocketFactory
=
new
class
implements
IWebSocketFactory
{
connect
(
host
:
string
,
port
:
number
,
query
:
string
,
callback
:
IConnectCallback
):
void
{
const
errorListener
=
(
err
:
any
)
=>
callback
(
err
,
undefined
);
const
socket
=
new
WebSocket
(
`ws://
${
host
}
:
${
port
}
/?
${
query
}
&skipWebSocketFrames=false`
);
socket
.
onopen
=
function
(
event
)
{
socket
.
removeEventListener
(
'
error
'
,
errorListener
);
callback
(
undefined
,
new
BrowserSocket
(
socket
));
};
socket
.
addEventListener
(
'
error
'
,
errorListener
);
}
};
src/vs/workbench/services/remote/browser/remoteAgentServiceImpl.ts
浏览文件 @
5509a96b
...
...
@@ -6,20 +6,25 @@
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IRemoteAgentConnection
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IRemoteAuthorityResolverService
}
from
'
vs/platform/remote/common/remoteAuthorityResolver
'
;
import
{
AbstractRemoteAgentService
}
from
'
vs/workbench/services/remote/common/abstractRemoteAgentService
'
;
import
{
AbstractRemoteAgentService
,
RemoteAgentConnection
}
from
'
vs/workbench/services/remote/common/abstractRemoteAgentService
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
browserWebSocketFactory
}
from
'
vs/platform/remote/browser/browserWebSocketFactory
'
;
export
class
RemoteAgentService
extends
AbstractRemoteAgentService
{
private
readonly
_connection
:
IRemoteAgentConnection
|
null
=
null
;
constructor
(
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IProductService
productService
:
IProductService
,
@
IRemoteAuthorityResolverService
remoteAuthorityResolverService
:
IRemoteAuthorityResolverService
)
{
super
(
environmentService
);
const
authority
=
document
.
location
.
host
;
this
.
_connection
=
this
.
_register
(
new
RemoteAgentConnection
(
authority
,
productService
.
commit
,
browserWebSocketFactory
,
environmentService
,
remoteAuthorityResolverService
));
}
getConnection
():
IRemoteAgentConnection
|
null
{
return
null
;
return
this
.
_connection
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录