Adding a Pusher container as a middleware/dispatcher between front and back
This commit is contained in:
parent
6c6d046891
commit
4c1e566a6c
86 changed files with 12172 additions and 983 deletions
22
pusher/src/Services/ApiClientRepository.ts
Normal file
22
pusher/src/Services/ApiClientRepository.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* A class to get connections to the correct "api" server given a room name.
|
||||
*/
|
||||
import {RoomManagerClient} from "../Messages/generated/messages_grpc_pb";
|
||||
import grpc from 'grpc';
|
||||
import {API_URL} from "../Enum/EnvironmentVariable";
|
||||
|
||||
|
||||
class ApiClientRepository {
|
||||
private roomManagerClient: RoomManagerClient|null = null;
|
||||
|
||||
public async getClient(roomId: string): Promise<RoomManagerClient> {
|
||||
if (this.roomManagerClient === null) {
|
||||
this.roomManagerClient = new RoomManagerClient(API_URL, grpc.credentials.createInsecure());
|
||||
}
|
||||
return Promise.resolve(this.roomManagerClient);
|
||||
}
|
||||
}
|
||||
|
||||
const apiClientRepository = new ApiClientRepository();
|
||||
|
||||
export { apiClientRepository };
|
Loading…
Add table
Add a link
Reference in a new issue