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 _SendModePic() { IHelloMessageData idata = DeviceHelloMessage.RecievedMessage.Data; var msg = Message.CreateModeMessage(MessageDataContainer.ModeType.Pic); CardBoardInterface.WriteDataBytes( Message2BytesComposer.ComposeMessageBytes(msg) , new IPEndPoint(idata.GetAdress(), idata.GetPort())); }
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); }
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); }