/// <summary> /// This method is the implementation of IConferenceServer. /// This methos is called from client side to connect to a particular meeting. /// This methods do the following things: /// -Search Conference from running conferences on this server--if found return conference room object /// otherwise search db & make new object of conferenceroom and return that /// -Create new AuthenticationMessage with profile.ClientId that is passed to JoinConference method. /// -Check conf==null then throw exception that specified conference id not found. /// -check conference capacity by executing query to mysql and throw exception in the case when capacity is full /// -sleep thread 1 seconds. /// -validate password of the meeting....its just empty function return true in all casees /// -Always else condition of if(!ValidateAuthentication(Password,"" + conferenceID)) statement run /// --check ctool_guest if IsGuest=true, if IsGuest=false then check ctool_company_member table /// --Assign Msg object different values like ftp_ip,username & password etc /// --check query result that is run again IsGuest true/false, assign different values to profile & msg object /// -check duplicate profile name..if found throw exception of duplicate user /// -this condition will not run because on previous statement we throw exception on same name /// if(cp.ClientRegistrationId == profile.ClientRegistrationId) // client exist in this meeting /// -conf.AttachClient(profile.Name,profile,Msg); will add the profile uri to dispatcher list so that /// user can get the message when some message is broadcast. /// -Add message join messages /// -insert profile.cleintid in the ctool_billing with billing_mtype=1 with quest and billing_mtype=0 for non-guest. /// -Select billing id against insertion and asssign it into the profile.billingid which further used in the billing consumer function named /// public void UpdateBillingInformation() /// -return conferenceroom object. /// </summary> /// <param name="conferenceID"></param> /// <param name="profile"></param> /// <param name="Msg"></param> /// <param name="Password"></param> /// <param name="IsGuest"></param> /// <returns></returns> public IConferenceRoom JoinConference(int conferenceID,ref WebMeeting.Common.ClientProfile profile,out AuthenticationMessage Msg, string Password,bool IsGuest) { Console.WriteLine(" On Join Called \n Going inside Search Conference"); ConferenceRoom conf; // // Find the conference // conf = SearchConference(conferenceID.ToString()); Msg = new AuthenticationMessage(profile.ClientId,true); //try //{ // // If conf not found, raise an error // if(conf == null) { throw (new System.ArgumentException("No conference with specified Id found hosted on this server", conferenceID.ToString())); } string sql = "select meeting_capacity from ctool_meeting where meeting_id = " + conf.ConferenceId; ArrayList Recordset = dbCon.Execute(sql); //Console.WriteLine(sql + "\n Execute. Recordset Count = " + Recordset.Count.ToString()); if(Recordset.Count < 1) { throw (new System.ArgumentException("No conference with specified Id found hosted on this server", conferenceID.ToString() )); } ArrayList Record = (ArrayList)Recordset[0]; int nTotal = Convert.ToInt32(Record[0]); if((conf.ClientList.Count + 1) > (nTotal+1)) { throw (new System.ArgumentException("No More users can join this conference. Conference Capacity reached", "Max" + conferenceID.ToString())); } //this sleep code should be removed as it slow the connection speed of the application. System.Threading.Thread.Sleep(1000); //ValidateAuthentication(Password,"" + conferenceID)--this method does nothing,its always send //true /* if(!ValidateAuthentication(Password,"" + conferenceID)) { Console.WriteLine("\nUser not validated "); throw (new System.ArgumentException("Invalid Meeting Password", Password)); } else */ { string sql2= "Select company_member_fname,company_member_email,company_acc_name From ctool_company_member,ctool_company_acc where company_acc_id = company_member_cid AND company_member_id = " + profile.ClientRegistrationId; if(IsGuest) { sql2 = "Select * from ctool_guest where guest_id = " + profile.ClientRegistrationId; } profile.IsGuest = IsGuest; ArrayList recordSet = dbCon.Execute(sql2); if(recordSet.Count < 1) { throw (new System.ArgumentException("No user exists with specified username","ClientRegistrationId")); } else { Msg.ConferenceName = conf.conferenceName; Msg.FTPPassoword = this.FTP_Password; Msg.FTPUsername = this.FTP_Username; Msg.FTPPort = this.FTP_PORT; Msg.FTP_IP = this.FTP_IP; Msg.ImageURL = GetImage("" + conferenceID); Msg.SenderID=-1; Msg.VoiceIP = voiceServerIP; Msg.VoicePort = voiceServerPort; Msg.voiceConferenceId = conf.conferenceVoiceSessionID; if(recordSet.Count > 0) { if(IsGuest) { ArrayList record = (ArrayList)recordSet[0]; string strFName =record[3].ToString(); profile.Name = strFName; profile.EMailAddress = record[4].ToString().ToLower(); Msg.companyName = "Guest Account"; Msg.ClientName = strFName; Msg.ClientEmail = profile.EMailAddress;//record[1].ToString().ToLower(); Msg.SenderID=-1; } else { ArrayList record = (ArrayList)recordSet[0]; string strFName =record[0].ToString(); profile.Name = strFName; profile.EMailAddress = record[1].ToString().ToLower(); profile.Name = strFName; Msg.companyName =record[2].ToString(); Msg.ClientName = strFName; Msg.ClientEmail = record[1].ToString().ToLower(); Msg.SenderID=-1; } } } } Console.WriteLine("profile name :::"+profile.Name); foreach(ClientProfile cp in conf.ClientList.Values) { Console.WriteLine("client List name :::"+cp.Name.Trim()); // To avoid the duplicate name if(cp.Name.Trim()==profile.Name.Trim()) { Console.WriteLine("Exception fired of login duplicate"); throw (new System.ArgumentException("A user is already login with name.", profile.Name.Trim())); } // if(cp.ClientRegistrationId == profile.ClientRegistrationId) // client exist in this meeting { // zaeem Vierw thios condition doesnt seem to be working ok // Wil see that later conf.checkConnectionUrgent(cp.ClientId ); //break; } } Console.WriteLine("Meeting Name " + Msg.ConferenceName); Console.WriteLine("\n Calling AttachClient"); conf.AttachClient(profile.Name,profile,Msg); Console.WriteLine("\n Attach Client Called"); GenuineUtility.CurrentSession["Profile"] = profile; //******************** Logging ST_flowMsg FlowMsgObj = new ST_flowMsg (); FlowMsgObj.meetID = conf.ConferenceId ; FlowMsgObj.curDate= DateTime.Now.Year + "-" + DateTime.Now.Month +"-" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; FlowMsgObj.curMsg = profile.Name + " has joined the "+ conf.conferenceName +" conference ." ; FlowMsgObj.MsgCategory = "Attendee Joins and Leaves"; //Zaeem Removed logging //flowMsgs.Add(FlowMsgObj); FlowMsgObj = null; return conf; /* } catch(Exception exp) { Console.WriteLine("******** Exception in Join conference **********"); Console.WriteLine(exp.Message.ToString()); Console.WriteLine(exp.StackTrace.ToString()); Console.WriteLine("********End Exception in Join conference **********"); return conf; } */ }
public void addFlowMsgs(string datetime, string curMessage, string msgCategory) { try { ST_flowMsg FlowMsgObj = new ST_flowMsg (); //FlowMsgObj.meetID = Convert.ToInt32(profile.ConferenceID) ; FlowMsgObj.curDate= datetime; FlowMsgObj.curMsg = curMessage; FlowMsgObj.MsgCategory = msgCategory; /*FlowMsgObj.question = ""; FlowMsgObj.answer = ""; FlowMsgObj.userid = ""; FlowMsgObj.usertype = ""; FlowMsgObj.qtype = ""; */ //flowMsgs.Add(FlowMsgObj); FlowMsgObj = null; } catch(Exception ex) { ex=ex; } }
/// <summary> /// Used to Marked a meeting closed. /// This method only called from the public void CloseConference(MessageObject msg)--ConferenceRoom /// with parameter ConferenceServer.staticServerInstance.CloseConference(this,true); /// so code in if(!ForceClose) never run, should be commented. /// This function do the following things /// -update ctool_meeting tables with meeting_completed = 1 /// -send attendeDropped message to all participant to passed conf object. /// -Add log that shows this conference is closed. /// -Remove passed conference object from the RunningConferenceList.ConfList hash table /// -Assign Conf set to null for garbage collector to collect. /// </summary> /// <param name="conf"></param> /// <param name="ForceClose"></param> public void CloseConference(ConferenceRoom conf,bool ForceClose) { try { string sql = "select meeting_date,meeting_time,meeting_dur from ctool_meeting where meeting_completed = 0 and meeting_id = " + conf.ConferenceId; if(!ForceClose) { ArrayList Recordset = dbCon.Execute(sql); if(Recordset.Count < 1) { return; } ArrayList Record = (ArrayList)Recordset[0]; string strdate = Record[0].ToString();// string[] date = strdate.Split('-'); int Year = Convert.ToInt32(date[0].ToString()); int Month = Convert.ToInt32(date[1].ToString()); int Day = Convert.ToInt32(date[2].ToLower()); string strTime = Record[1].ToString(); string[] time = strTime.Split(':'); int hour = Convert.ToInt32(time[0]); int min = Convert.ToInt32(time[1]); DateTime d = new DateTime(Year,Month,Day,hour,min,0); d.AddHours(Convert.ToInt32(Record[2].ToString())); if(d > DateTime.Now) return; } sql = "update ctool_meeting set meeting_completed = 1 WHERE meeting_id = " + conf.ConferenceId; dbCon.Execute(sql); try { foreach(ClientProfile client in conf.ClientList) { conf.RemoveClientFromConference(client.clientURI,false); } } catch(Exception ee) { } ST_flowMsg FlowMsgObj = new ST_flowMsg (); FlowMsgObj.meetID = conf.ConferenceId ; FlowMsgObj.curDate= DateTime.Now.Year + "-" + DateTime.Now.Month +"-" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; FlowMsgObj.curMsg = conf.conferenceName + " conference has closed." ; //flowMsgs.Add(FlowMsgObj); FlowMsgObj = null; //this.mconferenceVoices[conf.conferenceVoiceSessionID] = ConferenceVoiceEnum.Unused; RunningConferenceList.ConfList.Remove(conf.ConferenceId); conf.ShutDownConference(); conf = null; } catch(Exception ee) { ee =ee; } }
/// <summary> /// Catches Genuine Channels events and removes client session when /// user disconnects. /// This Method do the following things /// 1-show source exception if its not null else its show the profile information of user /// 2-Handling GeneralConnectionReestablishing,GeneralConnectionClosed event-types /// do following things on these events: /// -get profile using GenuineEventArgs e parameter....profile=e.HostInformation["Profile"] /// -by seaching conference staticServerInstance.SearchConference(profile.ConferenceID) use the /// DetachUser() method of conference room... /// DetachUser do two things /// -Remove URI from dispatcher list to assure that this paticipant no longer able to receive message /// -Send all participant a message of "ControlMessage" type with ControlCode.AttendeeDropped to update their Participant lists /// 3-Add message of leaving user from meeting /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void GenuineChannelsEventHandler(object sender, GenuineEventArgs e) { try { if (e.SourceException == null) #if TESTING Console.WriteLine("\r\n\r\n---Global event: {0}\r\nRemote host: {1}", e.EventType, e.HostInformation == null ? "<unknown>" : e.HostInformation.ToString()); #endif //else { #if TESTING Console.WriteLine("\r\n\r\n---Global event: {0}\r\nRemote host: {1}\r\nException: {2}", e.EventType, e.HostInformation == null ? "<unknown>" : e.HostInformation.ToString(), e.SourceException); #endif ClientProfile profile=e.HostInformation["Profile"] as ClientProfile; if(profile != null) { #if TESTING Console.WriteLine("An Exception has occured where profile Name = " + profile.Name); #endif } else { #if TESTING Console.WriteLine("An Exception has occured where profile was not found"); #endif } } /* Effect of handling event of type e.EventType == GenuineEventType.GeneralConnectionReestablishing "if a user disconnected from meeting then its clear all his participant list when its connected again it dont add user list that comes from server; to correct this problem we will write code in the client app to add users in the list." */ /* Some event types description * 1--GTcpConnectionAccepted--The GTCP server channel has accepted a connection. You can analyze the IP address of the remote host and decline * the connection. See the explanation below. * 2--GeneralConnectionEstablished--The GTCP client channel has connected to the server.The GTCP server channel has accepted a connection opened * by the client. * 3--GeneralConnectionReestablishing--The GTCP client channel recongnizes that the connection is broken but will attempt to reconnect to the server * automatically.The GTCP server channel recognizes that the connection is broken and the client is expected to reestablish the * connection within the specified time span. * 4--GeneralConnectionClosed--The GTCP server channel has released all resources * associated with an appropriate client connection and will not be able to accept a reconnection from it. * The GTCP client channel has closed the connection to the remote peer. */ /* some info about this event handler. * Belikov.GenuineChannels.DotNetRemotingLayer.GenuineGlobalEventProvider provides the global * GenuineChannelsGlobalEvent event fired for each Genuine Channels event. You can attach a * handler to it if you want to process events generated by all channels and services. */ if (e.EventType == GenuineEventType.GeneralConnectionClosed ||e.EventType == GenuineEventType.GeneralConnectionReestablishing ) { // the client disconnected ClientProfile profile=e.HostInformation["Profile"] as ClientProfile;//string ConnectionID= e.HostInformation["ConnectionID"] as string; staticServerInstance.SearchConference(profile.ConferenceID).DetachUser(profile); ST_flowMsg FlowMsgObj = new ST_flowMsg (); FlowMsgObj.meetID = profile.ConferenceID ; FlowMsgObj.curDate= DateTime.Now.Year + "-" + DateTime.Now.Month +"-" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; FlowMsgObj.curMsg = profile.Name +" has left from "+ profile.ConferenceID+ " conference." ; FlowMsgObj.MsgCategory = "Attendee Joins and Leaves"; //staticServerInstance.flowMsgs.Add(FlowMsgObj); FlowMsgObj = null; #if TESTING Console.WriteLine("Client \"{0}\" has been disconnected.", profile.ConferenceID); #endif } } catch(Exception) { } }