WIP
This commit is contained in:
parent
5663198733
commit
29d859b383
|
|
@ -13,17 +13,16 @@ class LongPollingTransport implements ITransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(url: string, queryString: string): Promise<void> {
|
connect(url: string, queryString: string): Promise<void> {
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
private poll(): void {
|
private poll(url: string): void {
|
||||||
this.pollXhr.open("GET", , true);
|
this.pollXhr.open("GET", url, true);
|
||||||
this.pollXhr.send();
|
this.pollXhr.send();
|
||||||
this.pollXhr.onload = () => {
|
this.pollXhr.onload = () => {
|
||||||
if (this.pollXhr.status >= 200 && this.pollXhr.status < 300) {
|
if (this.pollXhr.status >= 200 && this.pollXhr.status < 300) {
|
||||||
this.receiveCallback(this.pollXhr.response);
|
this.receiveCallback(this.pollXhr.response);
|
||||||
this.poll();
|
this.poll(url);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//TODO: handle error
|
//TODO: handle error
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ class RpcConnection {
|
||||||
private transport: ITransport;
|
private transport: ITransport;
|
||||||
private id: number;
|
private id: number;
|
||||||
|
|
||||||
constructor(url: string, queryString: string) {
|
constructor(url: string, queryString?: string) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.queryString = queryString;
|
this.queryString = queryString || "";
|
||||||
this.callbacks = new Map<string, (any) => void>();
|
this.callbacks = new Map<string, (any) => void>();
|
||||||
this.methods = new Map<string, (...args:any[]) => void>();
|
this.methods = new Map<string, (...args:any[]) => void>();
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
|
|
@ -53,6 +53,7 @@ class RpcConnection {
|
||||||
new HttpClient().get(this.url + "/getid?" + this.queryString)
|
new HttpClient().get(this.url + "/getid?" + this.queryString)
|
||||||
.then(id => {
|
.then(id => {
|
||||||
this.transport = new WebSocketTransport(data => this.messageReceived(data));
|
this.transport = new WebSocketTransport(data => this.messageReceived(data));
|
||||||
|
//this.transport = new LongPollingTransport(data => this.messageReceived(data));
|
||||||
return this.transport.connect(this.url, `id=${id}`);
|
return this.transport.connect(this.url, `id=${id}`);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue