Changed protocol to first wait for ACK from server on connection, this allows the server to reject clients.

This commit is contained in:
Sean Xu 2015-09-25 12:30:56 -07:00
Родитель ac4560655f
Коммит 3ee0e55224
2 изменённых файлов: 9 добавлений и 4 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -3,5 +3,6 @@
/projects/vs2015/bin
/projects/vs2015/obj
/projects/vs2015/.vs
/publish
*.csproj.user

Просмотреть файл

@ -23,12 +23,12 @@ module ProxyAdapter {
}
export function exit() {
ProxyAdapter.clearSession();
rpc("exit", null, true);
ProxyAdapter.clearSession();
}
export function launchAppx() {
rpc("launchAppx");
rpc("launchAppx", null, true);
}
export function registerAndLaunchAppxManifest(path: string) {
@ -57,12 +57,16 @@ function establishConnection(sessionOnly: boolean, callback: (socket: net.Socket
function doConnect(address: string, success: (socket: net.Socket) => any, error: (e: string) => any) {
var socket = new net.Socket();
socket.once("error", (e: string) => {
// Connection timed out or server forcefully disconnected
socket.destroy();
error(e);
});
socket.connect(6767, address, () => {
socket.removeAllListeners("error");
success(socket);
// Successfully connected, waiting on first ACK from server
socket.once("data", () => {
socket.removeAllListeners("error");
success(socket);
});
});
}