protected override void PeerConnection_onNewDataChannel(object sender, DataChannel e) { base.PeerConnection_onNewDataChannel(sender, e); if (e.label == nameof(ChannelName.fileChannel)) { FileChannelMessageDeal.RegisterFileChannel(e); } else { e.onChannelMessage += E_onChannelMessage; e.onChannelStateChanged += E_onChannelStateChanged; } }
/// <summary> /// 主动呼叫 /// </summary> /// <param name="mmachineId"></param> public bool ConnectRemote(string machineId) { this.remoteMachine = MachineLogic.GetMachineById(machineId); if (this.remoteMachine == null) { return(false); } this.InitlizeConnetion(); this.keyMouseChannel = this.PeerConnection.CreateDataChannel(ChannelName.keyMouseChannel.ToString()); this.fileChannel = this.PeerConnection.CreateDataChannel(ChannelName.fileChannel.ToString()); FileChannelMessageDeal.RegisterFileChannel(fileChannel); var offerInfo = this.PeerConnection.CreateOffer().Result; if (offerInfo == null) { this.showInfo("流媒体设备启动失败"); } WebSocketClient.SendMessage(machineId, offerInfo, msgType.client_onCaller_CreateOffer); return(true); }