Get CDN endpoint from server information
This commit is contained in:
parent
3a967e9ad7
commit
906391bfb6
|
@ -3,6 +3,8 @@ import { Response } from "./response.ts";
|
|||
import { answerChallenge, parseResponses, serializeRequests } from "./utils.ts";
|
||||
import { throwError } from "./utils.ts";
|
||||
|
||||
export class NotInitialized extends Error {}
|
||||
|
||||
export interface Session {
|
||||
id: string;
|
||||
publicHash: string;
|
||||
|
@ -15,8 +17,12 @@ export class BaseClient {
|
|||
|
||||
constructor(
|
||||
public readonly rpcEndpoint: string,
|
||||
public readonly cdnEndpoint: string,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
async getCDNEndpoint(): Promise<string> {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
async sessionId() {
|
||||
if (!this._session) {
|
||||
|
@ -93,7 +99,7 @@ export class BaseClient {
|
|||
}
|
||||
|
||||
async sendCDN(data: FormData) {
|
||||
const response = await fetch(this.cdnEndpoint, {
|
||||
const response = await fetch(await this.getCDNEndpoint(), {
|
||||
method: "POST",
|
||||
body: data,
|
||||
});
|
||||
|
|
|
@ -25,9 +25,8 @@ export class Client extends BaseClient {
|
|||
constructor(
|
||||
store: Memory | FileName | LocalStorageKey | Store = "main",
|
||||
rpcEndpoint = "http://socialvoid.qlg1.com:5601",
|
||||
cdnEndpoint = "http://socialvoid.qlg1.com:5602",
|
||||
) {
|
||||
super(rpcEndpoint, cdnEndpoint);
|
||||
super(rpcEndpoint);
|
||||
|
||||
this.store = typeof store === "undefined"
|
||||
? new MemoryStore()
|
||||
|
@ -50,6 +49,10 @@ export class Client extends BaseClient {
|
|||
this.cloud = new Cloud(this);
|
||||
}
|
||||
|
||||
async getCDNEndpoint(): Promise<string> {
|
||||
return (await this.help.getServerInformation()).cdn_server;
|
||||
}
|
||||
|
||||
async newSession() {
|
||||
if (this._session) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue