/// <summary> /// Joins a Smash session. User+email+device must be unique across all joinees of a session. /// </summary> /// <param name="identity">ClientIdentity object used for authentication.</param> /// <param name="dispatcher">The Dispatcher object. a dispatcher must be specified in order to use data binding with Smash.</param> /// <param name="meetingToken">The meeting token of the session to join.</param> /// <param name="user">User name joining the session.</param> /// <param name="email">email address of the user joining the session.</param> /// <param name="device">Device name of the user joining the session.</param> /// <param name="forceRejoin">A value of 'true' overrides user+email+device uniqueness requirement for joining a session.</param> /// <param name="tables">Array of ISmashTable for all SmashTable objects to be associated with the joined session.</param> /// <param name="state">State to be passed as userState in the completion event args.</param> public void JoinSessionAsync(ClientIdentity identity, Dispatcher dispatcher, Guid meetingToken, string user, string email, string device, bool forceRejoin, ISmashTable[] tables, object state) { if (tables == null) { throw new ArgumentNullException("tables"); } if (tables.Length == 0) { throw new ArgumentException("tables.Length==0"); } Dictionary<int, ISmashTable> uniquenessCheck = new Dictionary<int, ISmashTable>(); foreach (var table in tables) { int hash = table.TypeHash; if (uniquenessCheck.ContainsKey(hash)) { throw new ArgumentException("tables: Two tables with identical types and names provided"); } uniquenessCheck.Add(hash,table); } IAsyncResult asyncResult = SmashClientREST.JoinSessionAsync( identity, meetingToken, user, email, device, forceRejoin, new ServiceAgent<Contracts.JoinSessionResponse>.OnCompleteDelegate( (response) => { JoinSessionCompletedArgs e = new JoinSessionCompletedArgs(response.Exception, response.Aborted, response.StateObject); if (response.Exception == null && !response.Aborted) { SmashSession session = new SmashSession(identity, dispatcher, meetingToken, response.SessionID, response.ClientID, tables); e.Session = session; } OnJoinSessionCompleted(e); }), state); SmashClientREST.HandleCompletion(asyncResult, state); }
/// <summary> /// Event raised upon completion of JoinSessionAsync. /// </summary> /// <param name="e"></param> private void OnJoinSessionCompleted(JoinSessionCompletedArgs e) { if (this.JoinSessionCompleted != null) { this.JoinSessionCompleted(this, e); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SessionManager_JoinSessionCompleted(object sender, JoinSessionCompletedArgs e) { this.session = e.Session; this.Dispatcher.BeginInvoke(() => { if (e.Error != null) { MessageBox.Show("err: " + e.Error.Message); } else { DataUse.Instance.RoomCreated = true; // MessageBox.Show("sent message "+DataUse.Instance.MessageToSend); if (DataUse.Instance.ActiveLocationMode) { SendText(DataUse.Instance.MessageToSend); } // } //this.Join.IsEnabled = true; //this.Create.IsEnabled = true; }); }