This commit is contained in:
crusader 2017-08-14 11:13:11 +09:00
parent 62617e5990
commit 9d43ba870b

View File

@ -7,6 +7,8 @@ import {
export type OnDisconnectFunc = () => void;
export type OnResponseFunc = (response: any) => void;
const PROTOCOL_NAME = '1.0';
type ID_TYPE = number;
interface RequestQueue {
@ -55,6 +57,7 @@ export default class WebSocketRPC {
return new Promise<any>((resolve, reject) => {
const requestID = this.getRequestID();
let request = new Request<ID_TYPE>(requestID, method, args);
request.Protocol = PROTOCOL_NAME;
this.conn.send(JSON.stringify(request));
this.requestQueue.set(requestID, {resolve: resolve, reject: reject});