Beispiel #1
0
        public void Send <T>(INMessage <T> message, Action <T> callback, Action <INError> errback)
        {
            // Set a collation ID to dispatch callbacks on receive
            string collationId = Guid.NewGuid().ToString();

            message.SetCollationId(collationId);

            // Track callbacks for message
            var pair = new KeyValuePair <Action <object>, Action <INError> >((data) =>
            {
                callback((T)data);
            }, errback);

            collationIds.Add(collationId, pair);

            var stream = new MemoryStream();

            message.Payload.WriteTo(stream);
            Logger.TraceFormatIf(Trace, "SocketWrite: {0}", message.Payload);
            transport.SendAsync(stream.ToArray(), (bool completed) =>
            {
                if (!completed)
                {
                    // The write may have failed; don't track it
                    collationIds.Remove(collationId);
                }
            });
        }
Beispiel #2
0
        // Implement handlers for each intent you wish to handle.
        // As an example for messages, you may wish to add HandleSearchForMessages and HandleSetMessageAttribute.

        public void HandleSearchForMessages(INSearchForMessagesIntent intent, Action <INSearchForMessagesIntentResponse> completion)
        {
            // Implement your application logic to find a message that matches the information in the intent.

            var userActivity = new NSUserActivity("INSearchForMessagesIntent");
            var response     = new INSearchForMessagesIntentResponse(INSearchForMessagesIntentResponseCode.Success, userActivity);

            // Initialize with found message's attributes
            var sender    = new INPerson(new INPersonHandle("*****@*****.**", INPersonHandleType.EmailAddress), null, "Sarah", null, null, null);
            var recipient = new INPerson(new INPersonHandle("+1-415-555-5555", INPersonHandleType.PhoneNumber), null, "John", null, null, null);
            var message   = new INMessage("identifier", "I am so excited about SiriKit!", NSDate.Now, sender, new INPerson[] { recipient });

            response.Messages = new INMessage[] { message };
            completion(response);
        }
Beispiel #3
0
 public void SendMessage(INMessage message)
 {
     _messagesApi.SendMessage(message.Dto);
 }
		// Implement handlers for each intent you wish to handle.
		// As an example for messages, you may wish to add HandleSearchForMessages and HandleSetMessageAttribute.

		public void HandleSearchForMessages (INSearchForMessagesIntent intent, Action<INSearchForMessagesIntentResponse> completion)
		{
			// Implement your application logic to find a message that matches the information in the intent.

			var userActivity = new NSUserActivity (nameof (INSearchForMessagesIntent));
			var response = new INSearchForMessagesIntentResponse (INSearchForMessagesIntentResponseCode.Success, userActivity);

			// Initialize with found message's attributes
			var sender = new INPerson (new INPersonHandle ("*****@*****.**", INPersonHandleType.EmailAddress), null, "Sarah", null, null, null);
			var recipient = new INPerson (new INPersonHandle ("+1-415-555-5555", INPersonHandleType.PhoneNumber), null, "John", null, null, null);
			var message = new INMessage ("identifier", "I am so excited about SiriKit!", NSDate.Now, sender, new INPerson [] { recipient });
			response.Messages = new INMessage [] { message };
			completion (response);
		}