public void FileCountRefresh() { var sendingFiles = FileChannelMessageDeal.GetAllSendingFileInfo(); var recivingFiles = FileChannelMessageDeal.GetAllRecivingingFileInfo(); Application.Current.Dispatcher.BeginInvoke(new Action(() => { CurrentSendFiles.Clear(); CurrentRecivesFiles.Clear(); foreach (var item in sendingFiles) { CurrentSendFiles.Add( new FragState { FileGuid = item.fileGuid, FileLocalName = item.fileName, PersentStr = cuteFilePercent(item) }); } foreach (var item in recivingFiles) { CurrentRecivesFiles.Add( new FragState { FileGuid = item.fileGuid, FileLocalName = item.fileGuid + "__" + item.fileName, PersentStr = cuteFilePercent(item) }); } })); }
private void startSendFile(object obj) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (this.controlContext == null || this.controlContext.fileChannel == null) { return; } FileChannelMessageDeal.SelectFileToSend(this.controlContext.fileChannel); })); }
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); }
public void CloseConnection() { this.PeerConnection.Close(); FileChannelMessageDeal.removeFileChannel(this.fileChannel); }
private void Button_Click(object sender, RoutedEventArgs e) { FileChannelMessageDeal.OpenFileDiction(); }