/// <summary> /// Send an image to a target device /// </summary> /// <param name="image">The image to send</param> /// <param name="imageName">The name of the image</param> /// <param name="targetDevice">The target device (NOTE - targetDevice.NetworkDevice must not be null)</param> /// <param name="gesture">The Gesture used to send the image</param> public void SendImage(Image image, String imageName, MSEDevice targetDevice, MSEGesture gesture) { SendImage(image, imageName, targetDevice.intersectionPoint, targetDevice.NetworkDevice, gesture); }
/// <summary> /// Send an image to a target device /// </summary> /// <param name="image">The image to send</param> /// <param name="imageName">The name of the image</param> /// <param name="targetDevice">The target IADevice (NOTE - targetDevice must not be null)</param> /// <param name="gesture">The Gesture used to send the image</param> public void SendImage(Image image, String imageName, Dictionary<string, double> intersectionPoint, IADevice targetDevice, MSEGesture gesture) { MemoryStream ms = new MemoryStream(); // Saves the image into the MemoryStream image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // Converts image to a byte array byte[] imageAsData = ms.ToArray(); if (imageAsData == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Only a valid image can be sent. Your image " + imageName + " was not valid"); return; } if (imageName == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: A valid image name is required to send images, your image name was null"); return; } if (targetDevice == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Target Device must has a non null NetworkDevice"); return; } //Create Request IARequest request = new IARequest(Routes.ImageRoute); request.Body = imageAsData; request.Parameters["imagename"] = imageName; request.Parameters["x"] = intersectionPoint["x"].ToString(); request.Parameters["y"] = intersectionPoint["y"].ToString(); request.Origin = this.IntAirAct.OwnDevice; this.IntAirAct.SendRequest(request, targetDevice, delegate(IAResponse response, Exception error) { if (error == null) { logger.TraceEvent(TraceEventType.Error, 0, "Sending Image " + imageName + " to " + Routes.ImageRoute + "Failed"); } }); }
/// <summary> /// Send a Dictionary to another device /// </summary> /// <param name="dictionary">The dictionary to send</param> /// <param name="dictionaryType">The dictionary type. This is shown on the receiving end and so you can just it to differentiate dictionaries</param> /// <param name="targetDevice">The target device (NOTE - targetDevice.NetworkDevice must not be null)</param> /// <param name="gesture">The Gesture used to send the image</param> public void SendDictionary(Dictionary<string, string> dictionary, String dictionaryType, MSEDevice targetDevice, MSEGesture gesture) { SendDictionary(dictionary, dictionaryType, targetDevice.intersectionPoint, targetDevice.NetworkDevice, gesture); }
/// <summary> /// Send a Dictionary to another device /// </summary> /// <param name="dictionary">The dictionary to send</param> /// <param name="dictionaryType">The dictionary type. This is shown on the receiving end and so you can just it to differentiate dictionaries</param> /// <param name="targetDevice">The target device (NOTE - targetDevice must not be null)</param> /// <param name="gesture">The Gesture used to send the image</param> public void SendDictionary(Dictionary<string, string> dictionary, string dictionaryType, Dictionary<string, double> intersectionPoint, IADevice targetDevice, MSEGesture gesture) { if (dictionary == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Only a valid dictionary can be sent. Your dictionary was null"); return; } if (dictionaryType == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: A valid dictionary type is required, your dictionary type was null"); return; } if (targetDevice == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Target Device must has a non null NetworkDevice"); return; } IARequest request = new IARequest(Routes.DictionaryRoute); request.Parameters["dictionarytype"] = dictionaryType; request.Parameters["x"] = intersectionPoint["x"].ToString(); request.Parameters["y"] = intersectionPoint["y"].ToString(); request.SetBodyWith(dictionary); request.Origin = this.IntAirAct.OwnDevice; if (request.Body == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Your dictionary of " + dictionaryType + " type, could not be serialized."); return; } this.IntAirAct.SendRequest(request, targetDevice, delegate(IAResponse response, Exception error) { if (error != null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Sending Dictionary " + dictionaryType + " to " + Routes.DictionaryRoute + " Failed"); } }); }
/// <summary> /// Send Data to another Device /// </summary> /// <param name="data">The data to send</param> /// <param name="targetDevice">The target device (NOTE - targetDevice.NetworkDevice must not be null)</param> /// <param name="gesture">The Gesture used to send the image</param> public void SendData(byte[] data, MSEDevice targetDevice, MSEGesture gesture) { SendData(data, targetDevice.intersectionPoint, targetDevice.NetworkDevice, gesture); }
/// <summary> /// Send Data to another Device /// </summary> /// <param name="data">The data to send</param> /// <param name="targetDevice">The target device (NOTE - targetDevice must not be null)</param> /// <param name="gesture">The Gesture used to send the image</param> public void SendData(byte[] data, Dictionary<string, double> intersectionPoint, IADevice targetDevice, MSEGesture gesture) { if (data == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Only valid data can be sent. Your data object was set to null"); return; } if (targetDevice == null) { logger.TraceEvent(TraceEventType.Error, 0, "MSE Error: Target Device must have a non null NetworkDevice"); return; } //Create Request IARequest request = new IARequest(Routes.DataRoute); request.Body = data; request.Parameters["x"] = intersectionPoint["x"].ToString(); request.Parameters["y"] = intersectionPoint["y"].ToString(); request.Origin = this.IntAirAct.OwnDevice; this.IntAirAct.SendRequest(request, targetDevice, delegate(IAResponse response, Exception error) { if (error != null) { logger.TraceEvent(TraceEventType.Error, 0, "Sending Data to " + Routes.DataRoute + " Failed"); } }); }