public ClientSession(string identity, GenericEnums.RoomType roomType) { try { _identity = identity; _peers = new PeerStates(); switch (roomType) { case GenericEnums.RoomType.Audio: AudioSessionState = GenericEnums.SessionState.Pending; break; case GenericEnums.RoomType.Video: AudioSessionState = GenericEnums.SessionState.Pending; VideoSessionState = GenericEnums.SessionState.Pending; break; case GenericEnums.RoomType.Remoting: RemotingSessionState = GenericEnums.SessionState.Pending; break; } _pendingTransfer = new PendingTransfer(); _pendingTransfer.Audio = false; _pendingTransfer.Video = false; _pendingTransfer.Remoting = false; _transferUpdating = new ConferenceStatus(); _transferUpdating.IsAudioStatusUpdating = false; _transferUpdating.IsVideoStatusUpdating = false; _transferUpdating.IsRemotingStatusUpdating = false; } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public FormContact(GenericEnums.FormMode formMode, EventHandler contactsUpdated) { try { _formMode = formMode; _contactsUpdated = contactsUpdated; InitializeComponent(); SetFormMode(); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public FormContact(GenericEnums.FormMode formMode, ContactBase contact, EventHandler contactsUpdated) { try { _formMode = formMode; _contactsUpdated = contactsUpdated; _contactNo = contact.ContactNo; InitializeComponent(); SetFormMode(); // retrieve contact info txtFriendlyName.Text = contact.FriendlyName; txtIdentity.Text = contact.Identity; } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public IList<string> GetConnectedSessions(GenericEnums.RoomType roomType) { lock (_syncSessions) { IList<string> sessions = new List<string>(); if (_clientSessions != null) { foreach (ClientSession session in _clientSessions.Values) { switch (roomType) { case GenericEnums.RoomType.Audio: if (session.AudioSessionState == GenericEnums.SessionState.Opened || session.AudioSessionState == GenericEnums.SessionState.Pending || session.AudioSessionState == GenericEnums.SessionState.Paused) { sessions.Add(session.Identity); } break; case GenericEnums.RoomType.Video: if (session.VideoSessionState == GenericEnums.SessionState.Opened || session.VideoSessionState == GenericEnums.SessionState.Pending || session.VideoSessionState == GenericEnums.SessionState.Paused) { sessions.Add(session.Identity); } break; case GenericEnums.RoomType.Remoting: if (session.RemotingSessionState == GenericEnums.SessionState.Opened || session.RemotingSessionState == GenericEnums.SessionState.Pending || session.RemotingSessionState == GenericEnums.SessionState.Paused) { sessions.Add(session.Identity); } break; } } } return sessions; } }
public bool IsRoomActivated(string identity, GenericEnums.RoomType roomType) { bool activated = false; try { lock (_syncRooms) { string roomID = GenerateRoomID(identity, roomType); bool roomExists = _rooms.ContainsKey(roomID); if (roomExists) { activated = _rooms[roomID].RoomType == roomType; } } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } return activated; }
public void AddSession(Session session, GenericEnums.RoomType scope) { try { lock (_syncSessions) { if (_clientSessions == null) { _clientSessions = new Dictionary<string, ClientSession>(); } if (_clientSessions.ContainsKey(((ClientSession)session).Identity) == false) { _clientSessions.Add(((ClientSession)session).Identity, (ClientSession)session); } else { switch (scope) { case GenericEnums.RoomType.Audio: _clientSessions[((ClientSession)session).Identity].AudioSessionState = ((ClientSession)session).Peers.AudioSessionState; break; case GenericEnums.RoomType.Remoting: _clientSessions[((ClientSession)session).Identity].RemotingSessionState = ((ClientSession)session).Peers.RemotingSessionState; break; case GenericEnums.RoomType.Video: _clientSessions[((ClientSession)session).Identity].VideoSessionState = ((ClientSession)session).Peers.VideoSessionState; break; } } } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
/// <summary> /// method used to find out if specific confrence room is active /// </summary> /// <param name="identity"></param> /// <param name="roomType"></param> /// <returns></returns> public bool IsRoomActivated(string identity, GenericEnums.RoomType roomType) { return _roomManager.IsRoomActivated(identity, roomType); }
/// <summary> /// method used to reset the actions controls labels /// </summary> /// <param name="roomType"></param> public void ResetLabels(GenericEnums.RoomType roomType) { try { // call the labels update for each room type _formActions.UpdateLabels(true, true, roomType); if (roomType == GenericEnums.RoomType.Video) { // reset the audio labels also _formActions.UpdateLabels(true, true, GenericEnums.RoomType.Audio); } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
/// <summary> /// method used to update the actions controls labels based on partner conference status /// </summary> /// <param name="identity"></param> /// <param name="roomType"></param> public void UpdateLabels(string identity, GenericEnums.RoomType roomType) { try { if (string.IsNullOrEmpty(identity)) { // call the labels update for each room type _formActions.UpdateLabels(true, true, GenericEnums.RoomType.Undefined); } else { PeerStates peers = _model.SessionManager.GetPeerStatus(identity); GenericEnums.SessionState sessionState = _model.SessionManager.GetSessionState(identity, roomType); bool start = sessionState == GenericEnums.SessionState.Opened || sessionState == GenericEnums.SessionState.Paused || sessionState == GenericEnums.SessionState.Pending ? false : true; bool pause = sessionState == GenericEnums.SessionState.Paused ? false : true; // call the labels update for each room type _formActions.UpdateLabels(start, pause, roomType); } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public Contact(int contactNo, string identity, GenericEnums.ContactStatus newStatus) { ContactNo = contactNo; Identity = identity; Status = newStatus; }
/// <summary> /// method used to provide file transfer permission response to partner enquiry /// </summary> /// <param name="identity"></param> /// <param name="fileName"></param> /// <param name="fileSize"></param> /// <returns></returns> public bool RequestConferencePermission(string identity, GenericEnums.RoomType roomType) { bool canStart = false; try { _formMain.Invoke(new MethodInvoker(delegate() { _formMain.TopMost = true; })); _formMain.Invoke(new MethodInvoker(delegate() { _formMain.BringToFront(); })); string friendlyName = ((Contact)_model.GetContact(identity)).FriendlyName; _formMain.Invoke(new MethodInvoker(delegate() { DialogResult dialogResult = MessageBox.Show(_formMain, string.Format("{0} is asking of {1} conference permission. Do you agree?", friendlyName, roomType.ToString()), "Conference confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { canStart = true; } })); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } finally { _formMain.Invoke(new MethodInvoker(delegate() { _formMain.TopMost = false; })); } return canStart; }
public void UpdateLabels(bool start, bool pause, GenericEnums.RoomType roomType) { try { switch (roomType) { case GenericEnums.RoomType.Video: if (pause) { btnPauseVideo.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); } else { btnPauseVideo.Text = ButtonStatus.ButtonPauseStatus.Resume.ToString(); } if (start) { btnVideo.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); } else { btnVideo.Text = ButtonStatus.ButtonStartStatus.Stop.ToString(); } break; case GenericEnums.RoomType.Audio: if (pause) { btnMuteAudio.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); } else { btnMuteAudio.Text = ButtonStatus.ButtonPauseStatus.Resume.ToString(); } if (start) { btnAudio.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); } else { btnAudio.Text = ButtonStatus.ButtonStartStatus.Stop.ToString(); } break; case GenericEnums.RoomType.Remoting: if (pause) { btnPauseRemote.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); } else { btnPauseRemote.Text = ButtonStatus.ButtonPauseStatus.Resume.ToString(); } if (start) { btnRemote.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); } else { btnRemote.Text = ButtonStatus.ButtonStartStatus.Stop.ToString(); } break; case GenericEnums.RoomType.Undefined: btnVideo.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); btnPauseVideo.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); btnRemote.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); btnPauseRemote.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); btnAudio.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); btnMuteAudio.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); break; } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public void WaitRoomButtonAction(string partnerIdentity, string myIdentity, GenericEnums.RoomType roomType, bool wait) { try { MViewerClient client = null; if (!_clients.ContainsKey(partnerIdentity)) { AddClient(partnerIdentity); } else { client = (MViewerClient)_clients[partnerIdentity]; if (client.State != CommunicationState.Created && client.State != CommunicationState.Opened) { AddClient(partnerIdentity); } } client = (MViewerClient)_clients[partnerIdentity]; try { client.WaitRoomButtonAction(myIdentity, roomType, wait); } catch { } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public void UpdateContactStatus(string senderIdentity, GenericEnums.ContactStatus newStatus) { try { // propagate the update to the UI, through the controller _controllerHandlers.ContactsObserver.Invoke(this, new ContactsEventArgs() { Operation = GenericEnums.ContactsOperation.Status, UpdatedContact = new Contact(-1, senderIdentity, newStatus) } ); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public GenericEnums.SessionState GetSessionState(string identity, GenericEnums.RoomType roomType) { GenericEnums.SessionState returnState = GenericEnums.SessionState.Undefined; lock (_syncSessions) { if (_clientSessions != null && _clientSessions.ContainsKey(identity)) { switch (roomType) { case GenericEnums.RoomType.Video: returnState = _clientSessions[identity].VideoSessionState; break; case GenericEnums.RoomType.Audio: returnState = _clientSessions[identity].AudioSessionState; break; case GenericEnums.RoomType.Remoting: returnState = _clientSessions[identity].RemotingSessionState; break; } } } return returnState; }
void UpdateContactStatus(string identity, GenericEnums.ContactStatus newStatus) { try { IEnumerable<DataRow> enumerable = _contactsDataSet.Tables[0].AsEnumerable(). Where(s => s.Field<string>("Identity").Equals(identity)); if (enumerable.Count() > 0) { DataRow contact = enumerable.ElementAt(0); if (contact != null) { contact["Status"] = newStatus.ToString(); } } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public void UpdateLabels(bool start, bool pause, GenericEnums.RoomType roomType) { try { bool retry = true; while (retry) { try { this.Invoke(myDelegate, start, pause, roomType); retry = false; } catch (Exception) { retry = true; Thread.Sleep(2000); } } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } finally { // todo: fix the actions form focus issue //if (!this.Focused) //{ // this.Invoke(new MethodInvoker(delegate() // { // this.TopMost = true; // this.BringToFront(); // this.Activate(); // })); //} } }
/// <summary> /// method used to notify online contacts of new status /// </summary> /// <param name="newStatus"></param> public void NotifyContacts(GenericEnums.ContactStatus newStatus) { try { // retrieve a list of contact identities and tell them about your new status string[] identities = this.GetOnlineContactIdentities(); foreach (string identity in identities) { _clientController.AddClient(identity); _clientController.UpdateContactStatus(identity, ((Identity)Identity).MyIdentity, newStatus); RemoveClient(identity); } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public void SendRoomCommand(string myIdentity, string identity, GenericEnums.RoomType roomType, GenericEnums.SignalType signalType) { try { MViewerClient client = null; if (!_clients.ContainsKey(identity)) { AddClient(identity); } else { client = (MViewerClient)_clients[identity]; if (client.State != CommunicationState.Created && client.State != CommunicationState.Opened) { AddClient(identity); } } client = (MViewerClient)_clients[identity]; client.SendRoomButtonAction(myIdentity, roomType, signalType); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public void UpdateContactStatus(string partnerIdentity, string myIdentity, GenericEnums.ContactStatus newStatus) { try { MViewerClient client = null; if (!_clients.ContainsKey(partnerIdentity)) { AddClient(partnerIdentity); } else { client = (MViewerClient)_clients[partnerIdentity]; if (client.State != CommunicationState.Created && client.State != CommunicationState.Opened) { AddClient(partnerIdentity); } } client = (MViewerClient)_clients[partnerIdentity]; client.UpdateContactStatus(myIdentity, newStatus); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
/// <summary> /// method used to tell the video streaming to wait for conference room button action to finish /// </summary> /// <param name="wait"></param> public void WaitRoomButtonAction(bool wait, GenericEnums.RoomType roomType) { try { switch (roomType) { case GenericEnums.RoomType.Audio: // audio freeze logic PresenterManager.Instance(SystemConfiguration.Instance.PresenterSettings).FreezeAudio(wait); break; case GenericEnums.RoomType.Video: if (_formWebCapture != null) { _formWebCapture.WaitRoomButtonAction(wait); } break; case GenericEnums.RoomType.Remoting: // remoting freeze logic PresenterManager.Instance(SystemConfiguration.Instance.PresenterSettings).FreezeRemoting(wait); break; } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public void CloseRoom(string identity, GenericEnums.RoomType roomType) { try { lock (_syncRooms) { string roomID = GenerateRoomID(identity, roomType); if (_rooms != null && _rooms.ContainsKey(roomID)) { _rooms[roomID].SyncClosing.Reset(); ((Form)_rooms[roomID]).Invoke(new Delegates.CloseDelegate(((Form)_rooms[roomID]).Close)); } } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
void ToggleStatusUpdate(GenericEnums.SignalType buttonType, Button button) { try { switch (buttonType) { case GenericEnums.SignalType.Start: if (button.Text == ButtonStatus.ButtonStartStatus.Start.ToString()) { button.Text = ButtonStatus.ButtonStartStatus.Stop.ToString(); } else { button.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); } break; case GenericEnums.SignalType.Stop: if (button.Text == ButtonStatus.ButtonStartStatus.Start.ToString()) { button.Text = ButtonStatus.ButtonStartStatus.Stop.ToString(); } else { button.Text = ButtonStatus.ButtonStartStatus.Start.ToString(); } break; case GenericEnums.SignalType.Pause: if (button.Text == ButtonStatus.ButtonPauseStatus.Pause.ToString()) { button.Text = ButtonStatus.ButtonPauseStatus.Resume.ToString(); } else { button.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); } break; case GenericEnums.SignalType.Resume: if (button.Text == ButtonStatus.ButtonPauseStatus.Pause.ToString()) { button.Text = ButtonStatus.ButtonPauseStatus.Resume.ToString(); } else { button.Text = ButtonStatus.ButtonPauseStatus.Pause.ToString(); } break; } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public bool RoomsLeft(GenericEnums.RoomType roomType) { return _rooms != null ? _rooms.Where(kv => kv.Value.RoomType == roomType).Count() > 0 ? true : false : false; }
public void WaitRoomButtonAction(string senderIdentity, GenericEnums.RoomType roomType, bool wait) { try { _controllerHandlers.WaitRoomActionObserver.Invoke(null, new RoomActionEventArgs() { Identity = senderIdentity, RoomType = roomType, SignalType = wait == true ? GenericEnums.SignalType.Wait : GenericEnums.SignalType.RemoveWait }); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public bool ConferencePermission(string partnerIdentity, string myIdentity, GenericEnums.RoomType roomType) { bool canStart = false; try { if (!_clients.ContainsKey(partnerIdentity)) { AddClient(partnerIdentity); } MViewerClient client = (MViewerClient)_clients[partnerIdentity]; client = (MViewerClient)_clients[partnerIdentity]; canStart = client.ConferencePermission(myIdentity, roomType); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } return canStart; }
public void ShowRoom(string identity, GenericEnums.RoomType roomType) { try { //lock (_syncRooms) { string roomID = GenerateRoomID(identity, roomType); if (_rooms != null && _rooms.ContainsKey(roomID)) { Application.Run((Form)_rooms[roomID]); } } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public bool ConferencePermission(string senderIdentity, GenericEnums.RoomType roomType) { bool canStart = false; try { RoomActionEventArgs args = new RoomActionEventArgs() { Identity = senderIdentity, RoomType = roomType }; // request permission from the user _controllerHandlers.ConferencePermissionObserver.Invoke(this, args); canStart = args.HasPermission; } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } return canStart; }
public void SendRoomButtonAction(string identity, GenericEnums.RoomType roomType, GenericEnums.SignalType signalType) { try { if (roomType == GenericEnums.RoomType.Audio) { _syncAudioCaptures.Reset(); } if (roomType == GenericEnums.RoomType.Video) { _syncVideoCaptures.Reset(); } if (roomType == GenericEnums.RoomType.Remoting) { _syncRemotingCaptures.Reset(); } _controllerHandlers.RoomButtonObserver.Invoke(this, new RoomActionEventArgs() { RoomType = roomType, Identity = identity, SignalType = signalType }); if (roomType == GenericEnums.RoomType.Audio) { _syncAudioCaptures.Set(); } if (roomType == GenericEnums.RoomType.Video) { _syncVideoCaptures.Set(); } if (roomType == GenericEnums.RoomType.Remoting) { _syncRemotingCaptures.Set(); } } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
string GenerateRoomID(string partnerID, GenericEnums.RoomType roomType) { return partnerID + roomType.ToString(); }