Exemplo n.º 1
0
 /// <summary>
 /// Deliver any kind of text message
 /// </summary>
 /// <param name="type"></param>
 /// <param name="message"></param>
 private void DeliverTextMessage(string type, string message)
 {
     if (type != PairingService.NFC_IBCS && type != PairingService.NFC_IBCS_ACK && type != PairingService.NFC_IBCS_KEY && type != PairingService.NFC_IBCS_KEY_ACK)
     {
         pDevice.PublishMessage(type, message, MessageWrittenHandler);
     }
     else
     {
         pDevice.PublishMessage(type, message);
     }
 }
        private void ButtonSend_Click(object sender, RoutedEventArgs e)
        {
            if (proximityDevice != null)
            {
                StopPublishingMessage();

                publishId        = proximityDevice.PublishMessage("Windows.SampleMessageType", TextSendMessage.Text, MessageTransmittedHandler);
                TextMessage.Text = @"Message Transmitting!!";
            }
        }
Exemplo n.º 3
0
        private void PublishInfo()
        {
            if (null != proximityDevice &&
                0 == publishingId)
            {
                                string info = "I love Surface Hub";

                publishingId = proximityDevice.PublishMessage("Windows.Contoso", info);

                Log("Publishing Info");
            }
        }
        public void SendNFCMessage()
        {
            ProximityDevice device = ProximityDevice.GetDefault();

            // Make sure NFC is supported
            if (device != null)
            {
                long Id = device.PublishMessage("Windows.SampleMessageType", "Hello World!");
                Debug.WriteLine("Published Message. ID is {0}", Id);

                // Store the unique message Id so that it
                // can be used to stop publishing this message
            }
        }
        private void btnPublish_Click(object sender, RoutedEventArgs e)
        {
            ProximityDevice device = ProximityDevice.GetDefault();

            // Prüfen ob NFC auf diesem Gerät verfügbar ist
            if (device != null)
            {
                if (_publishedMessageId > -1)
                {
                    device.StopPublishingMessage(_publishedMessageId);
                }
                _publishedMessageId = device.PublishMessage("Windows.WindowsDeveloper.MessageType", "Hallo Welt via NFC");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// When the app is started, start listening for other devices.
        /// </summary>
        /// <param name="sender">The CoronaRuntimeEnvironment that dispatched the event.</param>
        /// <param name="e">Provides the Lua event table's fields/properties.</param>
        private CoronaLabs.Corona.WinRT.ICoronaBoxedData OnStartSubscribeAndPublish(
            CoronaLabs.Corona.WinRT.CoronaRuntimeEnvironment sender,
            CoronaLabs.Corona.WinRT.CoronaLuaEventArgs e)
        {
            string str = "";

            // Fetch the "event.message" property.
            var boxedMessage = e.Properties.Get("message") as CoronaLabs.Corona.WinRT.CoronaBoxedString;

            if (boxedMessage == null)
            {
                // A "message" property was not provided or it was not of type string.
                // Return an error message to Lua describing what went wrong.
                return(CoronaLabs.Corona.WinRT.CoronaBoxedString.From("'event.message' is a required field."));
            }

            if (_subscribedMessageID == -1)
            {
                _subscribedMessageID = _proximityDevice.SubscribeForMessage("Windows.ProximityDemo", messageReceived);
                str += "Subscribed";
            }
            else
            {
                str += "Already Subscribed";
            }


            //Stop Publishing the current message.
            if (_publishedMessageID != -1)
            {
                _proximityDevice.StopPublishingMessage(_publishedMessageID);
            }

            string msg = boxedMessage.ToString();

            if (msg.Length > 0)
            {
                _publishedMessageID = _proximityDevice.PublishMessage("Windows.ProximityDemo", msg);
                str += " - Published";
            }
            else
            {
                str += " - Error Length 0";
            }


            // Return a success message to Lua.
            return(CoronaLabs.Corona.WinRT.CoronaBoxedString.From("Started Proximity: " + str));
        }
Exemplo n.º 7
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            ProximityDevice device = ProximityDevice.GetDefault();

            if (device != null)
            {
                long Id = device.PublishMessage("Windows.SampleMessageType", "Hello World!");
                //Debug.WriteLine("Published Message. ID is {0}", Id);

                // Store the unique message Id so that it
                // can be used to stop publishing this message
            }
        }