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