/// <summary> /// Output devices collection preparation /// </summary> private async void SetOutputDevices() { //try //{ Message message = new Message() { Section = "Repository", Parameter = new Parameter() { Key = "Entity", Value = "OutputDevice" } }; NetworkMessanger <Message> messanger = new NetworkMessanger <Message>(message); List <Entity> entityList = await messanger.SendAndRecieve <List <Entity> >(SettingsManager.Instance.Values["RepositoryServerPort"].ToString(), SettingsManager.Instance.Values["ServerIP"].ToString()); List <OutputDevice> outputDeviceList = entityList.Select(x => (OutputDevice)x).ToList(); OutputDevices = new ObservableCollection <OutputDevice>(outputDeviceList); //} //catch (COMException e) //{ // var dialog = new MessageDialog(e.Message, "We have a problem..."); // await dialog.ShowAsync(); // // throw; //} }
/// <summary> /// Send previously prepared request (private) /// </summary> /// <returns>Network Result (async)</returns> private static async Task <NetworkResults> SendRequest(Message message) { string serverPort = SettingsManager.Instance.Values["HardwareServerPort"].ToString(); string serverIP = SettingsManager.Instance.Values["ServerIP"].ToString(); NetworkMessanger <Message> request = new NetworkMessanger <Message>(message); return(await request.Send(serverPort, serverIP)); }
private async void Button_ButtonPressed(GpioPin sender, GpioPinValueChangedEventArgs args) { Message requestMessage = new Message() { Section = "Video", Command = "Request" }; NetworkMessanger <Message> messanger = new NetworkMessanger <Message>(requestMessage); await messanger.SendWithoutResult(SettingsManager.Instance.ClientServerPort.ToString(), SettingsManager.Instance.ClientIP); }
public void Init(int pId, bool pIsLocal, NetworkMessanger pNetworkMessanger, PlaygroundField playgroundField, GameUI pUi) { Id = pId; IsLocal = pIsLocal; networkMessanger = pNetworkMessanger; bodyParts = new List <BodyPart>(); for (int i = 0; i < bodyPartsCount; i++) { AddBodyPart(100 - i * 10); } PlaceAt(playgroundField); itemController = new ItemController(this, pUi.ItemPanel, pUi.ActionPanel); powerUpController = new PowerUpController(this, pUi.PowerUpPanel, pUi.ActionPanel); }
private void OnConnectionReceived(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args) { if (connectionRequested != null && Running) { IAsyncAction asyncAction = ThreadPool.RunAsync((workItem) => { StreamSocket s = args.Socket; Message resultMessage = new Message(); try { connectionRequested( this, s.Information.RemoteHostName.CanonicalName.ToString(), s.InputStream.AsStreamForRead(), s.OutputStream.AsStreamForWrite() ); resultMessage.Result = NetworkResults.Success; } catch (Exception ex) { Logger.Log(ex); resultMessage.Result = NetworkResults.Error; } finally { NetworkMessanger <Message> messanger = new NetworkMessanger <Message>(resultMessage); messanger.SendToStream(s.OutputStream.AsStreamForWrite()); } s.Dispose(); }); } }