public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { var identity = new ClientIdentity(model.EmailAddress, model.Password, UserAuthenticationMode.UsernameAndPassword); if (!identity.IsAuthenticated) { ModelState.AddModelError("", "The user name or password provided is incorrect."); } var principal = new ClientPrincipal(identity); FormsAuthentication.SetAuthCookie(principal.Identity.Name, false); Session["Principal"] = principal; HttpContext.User = principal; if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } return View(model); }
/// <summary> /// Initializes a new instance of the SmashBlobUploader class. /// </summary> /// <param name="identity"></param> /// <param name="m"></param> /// <param name="s"></param> /// <param name="c"></param> /// <param name="address"></param> /// <param name="signature"></param> internal SmashBlobUploader(ClientIdentity identity, Guid m, Guid s, Guid c, string address, string signature) { this.meetingToken = m; this.sessionID = s; this.clientID = c; this.blobAddress = address; this.blobSharedSignature = signature; this.identity = identity; }
internal static SecurityMay2017 CreateWindowsSecurity() { List <ClientIdentity> clientIdentities = new List <ClientIdentity>(); ClientIdentity clientIdentity = new ClientIdentity(); clientIdentity.Identity = "domain\\username"; clientIdentity.IsAdmin = true; clientIdentities.Add(clientIdentity); return(new SecurityMay2017 { ClusterCredentialType = CredentialType.Windows, ServerCredentialType = CredentialType.Windows, WindowsIdentities = new WindowsJanuary2017() { ClientIdentities = clientIdentities, ClusterIdentity = "domain\\machinegroup" } }); }
public async Task CreateGroup(ClientIdentity clientIdentity, string groupName, IReadOnlyList <string> memberIdList) { Console.WriteLine("---------------- CreateGroup ----------------"); Console.WriteLine("Client: {0}", clientIdentity.ToString()); var groupIdentity = new GroupIdentity() { GroupId = Guid.NewGuid().ToString("N"), GroupName = groupName, OwnerId = clientIdentity.ClientId }; foreach (var memberId in memberIdList) { await Groups.AddToGroupAsync(memberId, groupIdentity.GroupId); } await Clients.Clients(memberIdList).SendAsync(HubConstant.NotifyAddedToGroupMethod, groupIdentity, clientIdentity); groupLookup.Add(groupIdentity); }
/// <summary> /// Initializes the target. Can be used by inheriting classes /// to initialize logging. /// </summary> protected override void InitializeTarget() { base.InitializeTarget(); _machineName = GetMachineName(); string connectionString = string.Empty; string serviceUri = string.Empty; string tenantIdentity = string.Empty; string resourceIdentity = string.Empty; string clientIdentity = string.Empty; string accountName = string.Empty; string accessKey = string.Empty; var defaultLogEvent = LogEventInfo.CreateNullEvent(); try { connectionString = ConnectionString?.Render(defaultLogEvent); if (string.IsNullOrEmpty(connectionString)) { serviceUri = ServiceUri?.Render(defaultLogEvent); tenantIdentity = TenantIdentity?.Render(defaultLogEvent); resourceIdentity = ResourceIdentity?.Render(defaultLogEvent); clientIdentity = ClientIdentity?.Render(defaultLogEvent); accountName = AccountName?.Render(defaultLogEvent); accessKey = AccessKey?.Render(defaultLogEvent); } _cloudTableService.Connect(connectionString, serviceUri, tenantIdentity, resourceIdentity, clientIdentity, accountName, accessKey); InternalLogger.Trace("AzureDataTablesTarget(Name={0}): Initialized", Name); } catch (Exception ex) { InternalLogger.Error(ex, "AzureDataTablesTarget(Name={0}): Failed to create TableClient with connectionString={1}.", Name, connectionString); throw; } }
// POST api/<controller> public HttpResponseMessage Post([FromBody] AuthInfo info) { try { var clients = ClientIdentity.Select(id => id.ClientID == info.ClientID).ToList(); if (clients.Count == 0) { return(ServerUtil.returnStatus(HttpStatusCode.Unauthorized, "Authorization Failed")); } var client = clients[0]; if (WopiSecurity.MD5Encrypt(client.ClientSecret + ServerUtil.AuthenticationKey()) == info.SecureString) { var response = ServerUtil.returnStatus(HttpStatusCode.OK, "Success"); client.Token = WopiSecurity.MD5Encrypt(Guid.NewGuid().ToString()); client.Counter = 1; client.Save(); response.Content = new StringContent(client.Token); return(response); } else { return(ServerUtil.returnStatus(HttpStatusCode.Unauthorized, "Authorization Failed")); } } catch (Exception ex) { ServerUtil.LogException(ex); return(ServerUtil.returnStatus(HttpStatusCode.BadRequest, "Invalid Request")); } }
/// <summary> /// Helper method to initiate the call that deletes a group. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="group">Specifies a group to be deleted.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void DeleteGroupAsync( ClientIdentity clientIdentity, Group group, ServiceAgent<GroupResult>.OnCompleteDelegate onComplete, object stateObject = null) { DeleteGroupAgent agent = new DeleteGroupAgent( RelayService.HostName, clientIdentity, group, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to initiate the call that creates a new group. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="ttl">Specifies the time to live in the service</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void CreateGroupAsync( ClientIdentity clientIdentity, TimeSpan ttl, ServiceAgent<GroupResult>.OnCompleteDelegate onComplete, object stateObject = null) { CreateGroupAgent agent = new CreateGroupAgent( RelayService.HostName, clientIdentity, ttl, stateObject); agent.ProcessRequest(onComplete); }
internal RemotingProxy (Type type, ClientIdentity identity) : base (type, identity) { _sink = identity.ChannelSink; _hasEnvoySink = false; _targetUri = identity.TargetUri; }
/// <summary> /// Helper method to register a Name with the service. /// </summary> /// <param name="identity">The hawaii client identity.</param> /// <param name="name">Specifies a name to register.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user defined object.</param> private static void RegisterNameAsync( ClientIdentity identity, string name, ServiceAgent<NameRegistrationResult>.OnCompleteDelegate onComplete, object stateObject = null) { RegisterNameAgent agent = new RegisterNameAgent( RendezvousService.HostName, identity, name, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Creates a new smash session. /// </summary> /// <param name="identity">ClientIdentity object used for authentication.</param> /// <param name="meetingToken">The meeting token of the session to create. Needs to be shared to allow others to join the session.</param> /// <param name="subject">The name of the session.</param> /// <param name="organizer">The organizer of the session.</param> /// <param name="organizerEmail">email address of organizer of session.</param> /// <param name="attendees">List of user names allowed to join a session. A wildcard '*' matches all users attempting to join.</param> /// <param name="lifetime">The lifetime of the session. Can be up to 30 days. The session will automatically be erased after expiration of this timespan.</param> /// <param name="managementID">The owner's management secret required to enumerate, modify, wipe sessions.</param> /// <param name="state">State to be passed as userState in the completion event args.</param> public void CreateSessionAsync(ClientIdentity identity, Guid meetingToken, string subject, string organizer, string organizerEmail, IEnumerable<string> attendees, TimeSpan lifetime, Guid managementID, object state) { IAsyncResult asyncResult = SmashClientREST.CreateSessionAsync( identity, meetingToken, subject, organizer, organizerEmail, attendees, lifetime, managementID, new ServiceAgent<Contracts.CreateSessionResponse>.OnCompleteDelegate( (response) => { CreateSessionCompletedArgs e = new CreateSessionCompletedArgs(response.Exception, response.Aborted, response.StateObject); if (response.Exception == null && !response.Aborted) { e.MeetingToken = meetingToken; e.SessionID = response.SessionID; } OnCreateSessionCompleted(e); }), state); SmashClientREST.HandleCompletion(asyncResult, state); }
/// <summary> /// Determines if the user is authorized to access the WebAPI endpoint based on the bearer token /// </summary> protected override bool IsAuthorized(HttpActionContext actionContext) { //return true; try { // Parse the query string and ensure there is an access_token var header = actionContext.Request.Headers; //string X_SWA_ClientID; string X_SWA_Proof; //if (!header.Contains("X-SWA-ClientID")) //{ // return false; //} //else //{ // X_SWA_ClientID =String.Join(",",header.GetValues("X-SWA-ClientID").ToArray()); //} if (!header.Contains("X-SWA-Proof")) { return(false); } else { X_SWA_Proof = String.Join(",", header.GetValues("X-SWA-Proof").ToArray()); } try { lock (ClientIdentity.Handle) { var clients = ClientIdentity.Select(id => id.Token == X_SWA_Proof).ToList(); if (clients.Count == 0) { return(false); } else { return(true); } //var client = clients[0]; //if (clients[0].Token == X_SWA_Proof) //(WopiSecurity.MD5Encrypt(client.Token + client.Counter.ToString()) == header.GetValues("X-SWA-Proof").ToString()) //{ // //client.Counter += 1; // //client.Save(); // return true; //} //else //{ // return false; //} } } catch (Exception) { return(false); } } catch (Exception) { // Any exception will return false, but should probably return an alternate status codes return(false); } }
/// <summary> /// Helper method to initiate the service call that retrieves all grammars available on the server. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="onComplete">Specifies an "on complete" delegate handler.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void GetGrammarsAsync( ClientIdentity clientIdentity, ServiceAgent<SpeechServiceResult>.OnCompleteDelegate onComplete, object stateObject = null) { SpeechGrammarsAgent client = new SpeechGrammarsAgent( SpeechService.HostName, clientIdentity, stateObject); client.ProcessRequest(onComplete); }
public ClientPrincipal(ClientIdentity identity) { this.identity = identity; }
/// <summary> /// Initializes the target. Can be used by inheriting classes /// to initialize logging. /// </summary> protected override void InitializeTarget() { base.InitializeTarget(); string connectionString = string.Empty; string serviceUri = string.Empty; string tenantIdentity = string.Empty; string resourceIdentity = string.Empty; string clientIdentity = string.Empty; Dictionary <string, string> queueMetadata = null; var defaultLogEvent = LogEventInfo.CreateNullEvent(); try { connectionString = ConnectionString?.Render(defaultLogEvent); if (string.IsNullOrEmpty(connectionString)) { serviceUri = ServiceUri?.Render(defaultLogEvent); tenantIdentity = TenantIdentity?.Render(defaultLogEvent); resourceIdentity = ResourceIdentity?.Render(defaultLogEvent); clientIdentity = ClientIdentity?.Render(defaultLogEvent); } if (QueueMetadata?.Count > 0) { queueMetadata = new Dictionary <string, string>(); foreach (var metadata in QueueMetadata) { if (string.IsNullOrWhiteSpace(metadata.Name)) { continue; } var metadataValue = metadata.Layout?.Render(defaultLogEvent); if (string.IsNullOrEmpty(metadataValue)) { continue; } queueMetadata[metadata.Name.Trim()] = metadataValue; } } var timeToLive = RenderDefaultTimeToLive(); if (timeToLive <= TimeSpan.Zero) { timeToLive = default(TimeSpan?); } _cloudQueueService.Connect(connectionString, serviceUri, tenantIdentity, resourceIdentity, clientIdentity, timeToLive, queueMetadata); InternalLogger.Trace("AzureQueueStorageTarget - Initialized"); } catch (Exception ex) { if (string.IsNullOrEmpty(connectionString) && !string.IsNullOrEmpty(serviceUri)) { InternalLogger.Error(ex, "AzureQueueStorageTarget(Name={0}): Failed to create QueueClient with ServiceUri={1}.", Name, serviceUri); } else { InternalLogger.Error(ex, "AzureQueueStorageTarget(Name={0}): Failed to create QueueClient with connectionString={1}.", Name, connectionString); } throw; } }
/// <summary> /// Helper method to initiate the call that deletes KeyValue items by keys. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="keys">Specifies the keys to search.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void DeleteByKeysAsync( ClientIdentity clientIdentity, string[] keys, ServiceAgent<DeleteResult>.OnCompleteDelegate onComplete, object stateObject) { DeleteByKeysAgent agent = new DeleteByKeysAgent( KeyValueService.HostName, clientIdentity, keys, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to initiate the call that deletes KeyValue items. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="prefix">Specifies the search prefix keyword.</param> /// <param name="before">Specifies the timpstamp for delete operation.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void DeleteAsync( ClientIdentity clientIdentity, string prefix, DateTime before, ServiceAgent<DeleteResult>.OnCompleteDelegate onComplete, object stateObject) { DeleteAgent agent = new DeleteAgent( KeyValueService.HostName, clientIdentity, prefix, before, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to initiate the call that sets KeyValue item. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="items">Specifies the KeyValue items to create.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void SetAsync( ClientIdentity clientIdentity, KeyValueItem[] items, ServiceAgent<SetResult>.OnCompleteDelegate onComplete, object stateObject) { SetAgent agent = new SetAgent( KeyValueService.HostName, clientIdentity, items, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to initiate the call that gets KeyValue items. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="prefix">Specifies the search prefix keyword.</param> /// <param name="size">Specifies the size of result.</param> /// <param name="continuationToken">Specifies the continuation token.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void GetAsync( ClientIdentity clientIdentity, string prefix, int size, string continuationToken, ServiceAgent<GetResult>.OnCompleteDelegate onComplete, object stateObject) { GetAgent agent = new GetAgent( KeyValueService.HostName, clientIdentity, prefix, size, continuationToken, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to initiate the call that gets KeyValue items by key. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="key">Specifies a key to search.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void GetByKeyAsync( ClientIdentity clientIdentity, string key, ServiceAgent<GetByKeyResult>.OnCompleteDelegate onComplete, object stateObject) { GetByKeyAgent agent = new GetByKeyAgent( KeyValueService.HostName, clientIdentity, key, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Initializes the target. Can be used by inheriting classes /// to initialize logging. /// </summary> protected override void InitializeTarget() { base.InitializeTarget(); string connectionString = string.Empty; string serviceUri = string.Empty; string tenantIdentity = string.Empty; string resourceIdentity = string.Empty; string clientIdentity = string.Empty; Dictionary <string, string> blobMetadata = null; Dictionary <string, string> blobTags = null; var defaultLogEvent = LogEventInfo.CreateNullEvent(); try { connectionString = ConnectionString?.Render(defaultLogEvent); if (string.IsNullOrEmpty(connectionString)) { serviceUri = ServiceUri?.Render(defaultLogEvent); tenantIdentity = TenantIdentity?.Render(defaultLogEvent); resourceIdentity = ResourceIdentity?.Render(defaultLogEvent); clientIdentity = ClientIdentity?.Render(defaultLogEvent); } if (BlobMetadata?.Count > 0) { blobMetadata = new Dictionary <string, string>(); foreach (var metadata in BlobMetadata) { if (string.IsNullOrWhiteSpace(metadata.Name)) { continue; } var metadataValue = metadata.Layout?.Render(defaultLogEvent); if (string.IsNullOrEmpty(metadataValue)) { continue; } blobMetadata[metadata.Name.Trim()] = metadataValue; } } if (BlobTags?.Count > 0) { blobTags = new Dictionary <string, string>(); foreach (var tag in BlobTags) { if (string.IsNullOrWhiteSpace(tag.Name)) { continue; } var metadataValue = tag.Layout?.Render(defaultLogEvent); blobTags[tag.Name.Trim()] = metadataValue ?? string.Empty; } } _cloudBlobService.Connect(connectionString, serviceUri, tenantIdentity, resourceIdentity, clientIdentity, blobMetadata, blobTags); InternalLogger.Trace("AzureBlobStorageTarget - Initialized"); } catch (Exception ex) { if (string.IsNullOrEmpty(connectionString) && !string.IsNullOrEmpty(serviceUri)) { InternalLogger.Error(ex, "AzureBlobStorageTarget(Name={0}): Failed to create BlobClient with ServiceUri={1}.", Name, serviceUri); } else { InternalLogger.Error(ex, "AzureBlobStorageTarget(Name={0}): Failed to create BlobClient with connectionString={1}.", Name, connectionString); } throw; } }
private void LoadIdentity() { if (!File.Exists("identity.dat")) { Application.Run(new FrmCreateIdentity()); if (!File.Exists("identity.dat")) { MessageBox.Show(Resources.IdentityNotCreated, Resources.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(-1); } } try { using (var sr = new StreamReader("identity.dat")) { var json = sr.ReadToEnd(); var identity = ClientIdentity.Deserialize(json); LocalIdentity = identity; } } catch (UnauthorizedAccessException ex) { MessageBox.Show(Resources.IdentityAccessDenied + ex.Message); Environment.Exit(-1); } }
/// <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="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, ISmashTable[] tables, object state) { JoinSessionAsync(identity, dispatcher, meetingToken, user, email, device, false, tables, state); }
/// <summary> /// Helper method to initiate the service call that executes the speech-to-text translation. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="grammar">Specifies a grammar name.</param> /// <param name="speechBuffer"> /// Specifies a buffer containing the audio data to be translated to text. /// The audio buffer should have the following characteristics: /// 'SamplesPerSecond=16000', 'AudioBitsPerSample=16' and 'AudioChannel=Mono'. /// </param> /// <param name="onComplete">Specifies an "on complete" delegate handler.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void RecognizeSpeechAsync( ClientIdentity clientIdentity, string grammar, byte[] speechBuffer, ServiceAgent<SpeechServiceResult>.OnCompleteDelegate onComplete, object stateObject = null) { SpeechRecognitionAgent client = new SpeechRecognitionAgent( SpeechService.HostName, clientIdentity, grammar, speechBuffer, stateObject); client.ProcessRequest(onComplete); }
/// <summary> /// Gets info for a specific Smash session. /// </summary> /// <param name="identity">ClientIdentity object used for authentication.</param> /// <param name="meetingToken">The meeting token of the session to get info for.</param> /// <param name="sessionID">The session ID of the session to get info for.</param> /// <param name="state">State to be passed as userState in the completion event args.</param> public void GetSessionInfoAsync(ClientIdentity identity, Guid meetingToken, Guid sessionID, object state) { IAsyncResult asyncResult = SmashClientREST.GetSessionInfoAsync( identity, meetingToken, sessionID, new ServiceAgent<Contracts.GetSessionInfoResponse>.OnCompleteDelegate( (response) => { GetSessionInfoCompletedArgs e = new GetSessionInfoCompletedArgs(response.Exception, response.Aborted, response.StateObject); if (response.Exception == null && !response.Aborted) { e.SessionInfo = response.Session; } OnGetSessionInfoCompleted(e); }), state); SmashClientREST.HandleCompletion(asyncResult, state); }
internal RemotingProxy(Type type, ClientIdentity identity) : base(type, identity) { _sink = identity.ChannelSink; _hasEnvoySink = false; _targetUri = identity.TargetUri; }
public static void AddClientIdentity(ClientIdentity clientIdentity) { _clientIdentityDic.TryAdd(clientIdentity.Ip, clientIdentity); }
/// <summary> /// Enumerates all sessions created with a management secret. /// </summary> /// <param name="identity">ClientIdentity object used for authentication.</param> /// <param name="managementID">The owner's management secret required to enumerate, modify, wipe sessions.</param> /// <param name="state">State to be passed as userState in the completion event args.</param> public void EnumSessionsAsync(ClientIdentity identity, Guid managementID, object state) { IAsyncResult asyncResult = SmashClientREST.EnumSessionsAsync( identity, managementID, new ServiceAgent<Contracts.EnumSessionsResponse>.OnCompleteDelegate( (response) => { EnumSessionCompletedArgs e = new EnumSessionCompletedArgs(response.Exception, response.Aborted, response.StateObject); if (response.Exception == null && !response.Aborted) { e.SessionInfos = response.Sessions; } OnEnumSessionsCompleted(e); }), state); SmashClientREST.HandleCompletion(asyncResult, state); }
/// <summary> /// Helper method to disasociate a registeration id to a name with the service. /// </summary> /// <param name="identity">The hawaii client identity.</param> /// <param name="registration">Specifies a name registration object.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user defined object.</param> private static void DisassociateIdAsync( ClientIdentity identity, NameRegistration registration, ServiceAgent<NameRegistrationResult>.OnCompleteDelegate onComplete, object stateObject = null) { DisassociateIdAgent agent = new DisassociateIdAgent( RendezvousService.HostName, identity, registration, stateObject); agent.ProcessRequest(onComplete); }
/// <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> /// Helper method to initiate the call that creates an endpoint. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="name">Specifies a name of the client.</param> /// <param name="ttl">Specifies the time to live on the server</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void CreateEndPointAsync( ClientIdentity clientIdentity, string name, TimeSpan ttl, ServiceAgent<EndpointResult>.OnCompleteDelegate onComplete, object stateObject = null) { CreateEndPointAgent agent = new CreateEndPointAgent( RelayService.HostName, clientIdentity, name, ttl, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Wipes (erases) all contents of a Smash session and prevents any further operation on the session. /// </summary> /// <param name="identity">ClientIdentity object used for authentication.</param> /// <param name="meetingToken">The meeting token of the session to join.</param> /// <param name="sessionID">The session ID of the session to be wiped.</param> /// <param name="managementID">The owner's management secret required to enumerate, modify, wipe sessions.</param> /// <param name="state">State to be passed as userState in the completion event args.</param> public void WipeSessionAsync(ClientIdentity identity, Guid meetingToken, Guid sessionID, Guid managementID, object state) { IAsyncResult asyncResult = SmashClientREST.WipeSessionAsync( identity, meetingToken, sessionID, managementID, new ServiceAgent<Contracts.WipeSessionResponse>.OnCompleteDelegate( (response) => { WipeSessionCompletedArgs e = new WipeSessionCompletedArgs(response.Exception, response.Aborted, response.StateObject); OnWipeSessionCompleted(e); }), state); SmashClientREST.HandleCompletion(asyncResult, state); }
/// <summary> /// Helper method to initiate the call that deletes an endpoint. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="endpoint">Specifies an endpoint.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void DeleteEndPointAsync( ClientIdentity clientIdentity, Endpoint endpoint, ServiceAgent<EndpointResult>.OnCompleteDelegate onComplete, object stateObject = null) { DeleteEndPointAgent agent = new DeleteEndPointAgent( RelayService.HostName, clientIdentity, endpoint, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to recognize an image. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="imageBuffer"> /// Specifies a buffer containing an image that has to be processed. /// The image must be in JPEG format. /// </param> /// <param name="onComplete">Specifies an on complete callback method.</param> /// <param name="stateObject">Specifies a user defined object which will be provided in the call of the callback method.</param> private static void RecognizeImageAsync( ClientIdentity clientIdentity, byte[] imageBuffer, ServiceAgent<OcrServiceResult>.OnCompleteDelegate onComplete, object stateObject = null) { OcrAgent agent = new OcrAgent( OcrService.HostName, clientIdentity, imageBuffer, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to initiate the call that will send a message. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="fromEndPoint">Specifies an from end point.</param> /// <param name="recipientIds">Specifies the recipients (either endpoint or group) ids.</param> /// <param name="message">Specifies an message data to be sent.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void SendMessageAsync( ClientIdentity clientIdentity, Endpoint fromEndPoint, string recipientIds, byte[] message, ServiceAgent<MessagingResult>.OnCompleteDelegate onComplete, object stateObject = null) { SendMessageAgent agent = new SendMessageAgent( RelayService.HostName, clientIdentity, fromEndPoint, recipientIds, message, TimeSpan.MaxValue, stateObject); agent.ProcessRequest(onComplete); }
internal RealProxy(Type classToProxy, ClientIdentity identity) : this(classToProxy, IntPtr.Zero, null) { _objectIdentity = identity; }
/// <summary> /// Helper method to initiate the call that will receive a message. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="endpoint">Specifies an endpoint to leave a group.</param> /// <param name="filter"> /// Specifies a list of registration ids for Endpoints and/or Groups that /// identify senders and/or group recipients of desired messages. /// </param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void ReceiveMessagesAsync( ClientIdentity clientIdentity, Endpoint endpoint, string filter, ServiceAgent<MessagingResult>.OnCompleteDelegate onComplete, object stateObject = null) { ReceiveMessagesAgent agent = new ReceiveMessagesAgent( RelayService.HostName, clientIdentity, endpoint, filter, TimeSpan.Zero, // Default to return immediately stateObject); agent.ProcessRequest(onComplete); }