protected void HelloMessageProceed(Message msg, IPEndPoint localEndPoint) { bool isAlreadyContainDevice = false; IHelloMessageData iNewData = msg.Data; foreach (var deviceMessage in VirtualCardboardDevicesList) { IHelloMessageData iData = deviceMessage.RecievedMessage.Data; if (iData.GetName() == iNewData.GetName() && iData.GetAdress().Equals(iNewData.GetAdress()) && iData.GetPort() == iNewData.GetPort()) { isAlreadyContainDevice = true; break; } } if (!isAlreadyContainDevice) { VirtualCardboardDevicesList.Add( new ClientMessage() { RecievedMessage = msg , LocalEnpPoint = localEndPoint }); string name = ((IHelloMessageData)msg.Data).GetName(); Invoke(new MethodInvoker(delegate() { listBoxVirtualCardboardDevices.Items.Add(name); })); } }
private void _SendSettingsRequet() { Message msg = Message.CreateSettingsMessage( MessageDataContainer.MissionRequest, 0, 0, 0, 0 , DeviceHelloMessage.LocalEnpPoint.Address, CardBoardInterface.GetServerPort()); IHelloMessageData idata = DeviceHelloMessage.RecievedMessage.Data; CardBoardInterface.WriteDataBytes( Message2BytesComposer.ComposeMessageBytes(msg) , new IPEndPoint(idata.GetAdress(), idata.GetPort())); DeviceStatus = StatusWaiting; UpdateDeviceStatus(idata.GetName(), DeviceStatus); }
private void ViewSettings_Load(object sender, EventArgs e) { IHelloMessageData iData = DeviceHelloMessage.RecievedMessage.Data; lock (SyncStatus) { UpdateDeviceStatus(iData.GetName(), DeviceStatus); numericUpDownEyesDistance.Maximum = Decimal.MaxValue; numericUpDownHeigh.Maximum = Decimal.MaxValue; numericUpDownVerticalPosition.Maximum = Decimal.MaxValue; numericUpDownWidth.Maximum = Decimal.MaxValue; _SendModeSettings(); _SendSettingsRequet(); } }
protected void _SendSettingsRequestAssign() { Message msg = Message.CreateSettingsMessage( MessageDataContainer.MissionRequest | MessageDataContainer.MissionAssign , (int)numericUpDownEyesDistance.Value , (int)numericUpDownVerticalPosition.Value , (int)numericUpDownWidth.Value , (int)numericUpDownHeigh.Value , DeviceHelloMessage.LocalEnpPoint.Address, CardBoardInterface.GetServerPort()); IHelloMessageData idata = DeviceHelloMessage.RecievedMessage.Data; CardBoardInterface.WriteDataBytes( Message2BytesComposer.ComposeMessageBytes(msg) , new IPEndPoint(idata.GetAdress(), idata.GetPort())); DeviceStatus = StatusWaiting; UpdateDeviceStatus(idata.GetName(), DeviceStatus); }