|
@@ -2,7 +2,7 @@ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
|
import { ClientGrpc, Client } from '@nestjs/microservices';
|
|
|
import { grpcClientOptions } from './grpc-scene.options';
|
|
|
import { Logger } from '@nestjs/common';
|
|
|
-import { DataChannel } from 'node-datachannel';
|
|
|
+import { DataChannel, PeerConnection } from 'node-datachannel';
|
|
|
import { BehaviorSubject } from 'rxjs';
|
|
|
// import * as streamBuffers from 'stream-buffers';
|
|
|
import { ActionType } from './actionType';
|
|
@@ -46,6 +46,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
private sceneGrpcService: SceneGrpcService;
|
|
|
private channel: DataChannel;
|
|
|
+ private peer: PeerConnection;
|
|
|
private logger: Logger = new Logger('SceneService');
|
|
|
private frameCntInterval = 1000;
|
|
|
private user_id: string;
|
|
@@ -813,8 +814,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- handleDataChanelOpen(channel: DataChannel): void {
|
|
|
+ handleDataChanelOpen(channel: DataChannel, peer: PeerConnection): void {
|
|
|
this.channel = channel;
|
|
|
+ this.peer = peer;
|
|
|
this.streamService.setChannel(channel);
|
|
|
this.startSteaming.next(true);
|
|
|
this.startStream();
|
|
@@ -1021,6 +1023,15 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.frameCntSubscription = this.frameCnt.subscribe(async (frame) => {
|
|
|
try {
|
|
|
this.logger.log('frame', frame);
|
|
|
+ console.log(
|
|
|
+ 'mock' +
|
|
|
+ 'maxMessageSize: ' +
|
|
|
+ this.channel.maxMessageSize() +
|
|
|
+ 'bytesReceived: ' +
|
|
|
+ this.peer.bytesReceived() +
|
|
|
+ 'bytesSent: ' +
|
|
|
+ this.peer.bytesSent(),
|
|
|
+ );
|
|
|
if (frame === 1) {
|
|
|
const redisData = await this.rotateService.echo(this.user_id, true);
|
|
|
this.logger.log('获取-首屏', redisData);
|