/// <summary> /// Helper method to store the endpoint. /// </summary> /// <param name="endpoint">A valid endpoint.</param> public static void SaveEndpoint(Endpoint endpoint) { if (endpoint == null) { RelayStorage.RemoveKey(RelayStorage.EndpointKey); RelayStorage.RemoveKey(RelayStorage.JoinedGroupsKey); } else { string endpointValue = string.Format( "{0}{1}{2}", endpoint.RegistrationId, RelayStorage.ValueSeperator, endpoint.SecretKey); RelayStorage.SetValue(RelayStorage.EndpointKey, endpointValue); RelayStorage.SaveGroups(RelayStorage.JoinedGroupsKey, endpoint.Groups); } }
/// <summary> /// Hepler method to create endpoint using stored endpoint values. /// </summary> /// <returns>An endpoint.</returns> public static Endpoint ReadEndpoint() { string endpointValue = RelayStorage.GetValue(RelayStorage.EndpointKey); if (string.IsNullOrEmpty(endpointValue)) { return null; } Endpoint endpoint = null; string[] values = endpointValue.Split( new string[] { RelayStorage.ValueSeperator }, System.StringSplitOptions.RemoveEmptyEntries); if (values == null || values.Length != 2) { return null; } endpoint = new Endpoint() { RegistrationId = values[0], SecretKey = values[1], Groups = RelayStorage.ReadGroups(RelayStorage.JoinedGroupsKey) }; return endpoint; }
/// <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); }
/// <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); }
/// <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 initiate the call that will have an endpoint leave from a group. /// </summary> /// <param name="clientIdentity">The hawaii client identity.</param> /// <param name="endpoint">Specifies an endpoint to leave a group.</param> /// <param name="group">Specifies a target group.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> private static void LeaveGroupAsync( ClientIdentity clientIdentity, Endpoint endpoint, Group group, ServiceAgent<GroupResult>.OnCompleteDelegate onComplete, object stateObject = null) { LeaveGroupAgent agent = new LeaveGroupAgent( RelayService.HostName, clientIdentity, endpoint, group, stateObject); agent.ProcessRequest(onComplete); }
/// <summary> /// Helper method to initiate the call that will send a message. /// </summary> /// <param name="clientId">The adm client Id.</param> /// <param name="clientSecret">The adm client secret.</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> public static void SendMessageAsync( string clientId, string clientSecret, Endpoint fromEndPoint, string recipientIds, byte[] message, ServiceAgent<MessagingResult>.OnCompleteDelegate onComplete, object stateObject = null) { if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException("clientId"); } if (string.IsNullOrEmpty(clientSecret)) { throw new ArgumentNullException("clientSecret"); } SendMessageAsync( new AdmAuthClientIdentity(clientId, clientSecret, RelayService.ServiceScope), fromEndPoint, recipientIds, message, onComplete, stateObject); }
/// <summary> /// Helper method to initiate the call that will receive a message. /// </summary> /// <param name="clientId">The adm client Id.</param> /// <param name="clientSecret">The adm client secret. /// Specifies the Hawaii Application Id. /// </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> public static void ReceiveMessagesAsync( string clientId, string clientSecret, Endpoint endpoint, string filter, ServiceAgent<MessagingResult>.OnCompleteDelegate onComplete, object stateObject = null) { if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException("clientId"); } if (string.IsNullOrEmpty(clientSecret)) { throw new ArgumentNullException("clientSecret"); } ReceiveMessagesAsync( new AdmAuthClientIdentity(clientId, clientSecret, RelayService.ServiceScope), endpoint, filter, onComplete, stateObject); }
/// <summary> /// Helper method to initiate the call that will receive a message. /// </summary> /// <param name="hawaiiAppId"> /// Specifies the Hawaii Application Id. /// </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> public static void ReceiveMessagesAsync( string hawaiiAppId, Endpoint endpoint, string filter, ServiceAgent<MessagingResult>.OnCompleteDelegate onComplete, object stateObject = null) { if (string.IsNullOrEmpty(hawaiiAppId)) { throw new ArgumentNullException("hawaiiAppId"); } ReceiveMessagesAsync( new GuidAuthClientIdentity(hawaiiAppId), endpoint, filter, onComplete, stateObject); }
/// <summary> /// Helper method to initiate the call that will have an endpoint leave from a group. /// </summary> /// <param name="clientId">The adm client Id.</param> /// <param name="clientSecret">The adm client secret.</param> /// <param name="endpoint">Specifies an endpoint to leave a group.</param> /// <param name="group">Specifies a target group.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> public static void LeaveGroupAsync( string clientId, string clientSecret, Endpoint endpoint, Group group, ServiceAgent<GroupResult>.OnCompleteDelegate onComplete, object stateObject = null) { if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException("clientId"); } if (string.IsNullOrEmpty(clientSecret)) { throw new ArgumentNullException("clientSecret"); } LeaveGroupAsync( new AdmAuthClientIdentity(clientId, clientSecret, RelayService.ServiceScope), endpoint, group, onComplete, stateObject); }
/// <summary> /// Helper method to initiate the call that will send a message. /// </summary> /// <param name="hawaiiAppId">Specifies the Hawaii Application Id.</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> public static void SendMessageAsync( string hawaiiAppId, Endpoint fromEndPoint, string recipientIds, byte[] message, ServiceAgent<MessagingResult>.OnCompleteDelegate onComplete, object stateObject = null) { if (string.IsNullOrEmpty(hawaiiAppId)) { throw new ArgumentNullException("hawaiiAppId"); } SendMessageAsync( new GuidAuthClientIdentity(hawaiiAppId), fromEndPoint, recipientIds, message, onComplete, stateObject); }
/// <summary> /// Helper method to initiate the call that will have an endpoint leave from a group. /// </summary> /// <param name="hawaiiAppId">Specifies the Hawaii Application Id.</param> /// <param name="endpoint">Specifies an endpoint to leave a group.</param> /// <param name="group">Specifies a target group.</param> /// <param name="onComplete">Specifies an "on complete" delegate callback.</param> /// <param name="stateObject">Specifies a user-defined object.</param> public static void LeaveGroupAsync( string hawaiiAppId, Endpoint endpoint, Group group, ServiceAgent<GroupResult>.OnCompleteDelegate onComplete, object stateObject = null) { if (string.IsNullOrEmpty(hawaiiAppId)) { throw new ArgumentNullException("hawaiiAppId"); } LeaveGroupAsync( new GuidAuthClientIdentity(hawaiiAppId), endpoint, group, onComplete, stateObject); }
private void SendRequest(Endpoint from, string recipients) { byte[] message = Encoding.Unicode.GetBytes("FReq" + '\0' + (string)settings["MyUsername"]); RelayService.SendMessageAsync( HawaiiClient.HawaiiApplicationId, from, recipients, message, this.OnCompleteSendMessage); }
private void SendAccept(Endpoint from, string recipients) { byte[] message = Encoding.Unicode.GetBytes("Accept"); RelayService.SendMessageAsync( HawaiiClient.HawaiiApplicationId, from, recipients, message, this.OnCompleteSendAccept); }
private void SendProject(Endpoint from, string recipients) { if (!String.IsNullOrEmpty(recipients)) { byte[] message = editProj.Serialize(); RelayService.SendMessageAsync( HawaiiClient.HawaiiApplicationId, from, recipients, message, this.OnCompleteSendMessage); } else { MessagingResult ret = new MessagingResult(); ret.Status = Status.Success; OnCompleteSendMessage(ret); } }