private void SendBackOk(DownTransmission downTrans) { UpTransmisstion upTransmisstion = new UpTransmisstion() { Key = downTrans.Key, Code = UpTransmisstionCode.Ok, Desc = UpTransmisstion.GetDesc(UpTransmisstionCode.Ok), }; byte[] data = TransmissionUtil.SerializeAndCompress <UpTransmisstion>(upTransmisstion); SlaveClient.Send(data); upTransmisstion = null; data = null; }
public void GetBusInfo_Empty() { var result = new object[3] { 1, "bus info", new object[0] }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginGetBusInfoStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return(null); }; MSlaveProxy.AllInstances.EndGetBusInfoIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); //client.GetBusInfoAsync("/test").Result.Is(25346); }
public void GetSubscriptions_Empty() { var result = new object[3] { 1, "Success", new object[0] }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginGetSubscriptionsStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return(null); }; MSlaveProxy.AllInstances.EndGetSubscriptionsIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); client.GetSubscriptionsAsync("/test").Result.Count.Is(0); }
public void GetMasterUri_Success() { var result = new object[3] { 1, "", "http://localhost:11311" }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginGetMasterUriStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return(null); }; MSlaveProxy.AllInstances.EndGetMasterUriIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); client.GetMasterUriAsync("/test").Result.Is(new Uri("http://localhost:11311")); }
public void GetPid_Success() { var result = new object[3] { 1, "PID: 25346", 25346 }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginGetPidStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return(null); }; MSlaveProxy.AllInstances.EndGetPidIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); client.GetPidAsync("/test").Result.Is(25346); }
public void RequestTopic_NoPublisher() { var result = new object[3] { -1, "No publishers for topic: /chatter", "null" }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginRequestTopicStringStringObjectArrayAsyncCallbackObject = (t1, t2, t3, t4, t5, t6) => { t5(null); return(null); }; MSlaveProxy.AllInstances.EndRequestTopicIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); client.RequestTopicAsync("/test", "/chatter", new List <ProtocolInfo> { new ProtocolInfo(ProtocolType.TCPROS) }).Wait(); }
public void PublisherUpdate_Success() { var result = new object[3] { 1, "Publisher update received.", 0 }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginPublisherUpdateStringStringStringArrayAsyncCallbackObject = (t1, t2, t3, t4, t5, t6) => { t5(null); return(null); }; MSlaveProxy.AllInstances.EndPublisherUpdateIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); client.PublisherUpdateAsync("/test", "topic", new string[1] { "http://192.168.1.2:8989" }).Wait(); }
public void GetBusStats_Unknown() { var result = new object[3] { -1, "unknown node [/test]", "" }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginGetBusStatsStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return(null); }; MSlaveProxy.AllInstances.EndGetBusStatsIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); var ex = AssertEx.Throws <AggregateException>(() => client.GetBusStatsAsync("/test").Wait()); ex.InnerException.Message.Is("unknown node [/test]"); }
public void RequestTopic_Success() { var result = new object[3] { 1, "Protocol<TCPROS, AdvertiseAddress<192.168.11.4, 38939>>", new object[3] { "TCPROS", "192.168.11.4", 38939 } }; MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { }; MSlaveProxy.AllInstances.BeginRequestTopicStringStringObjectArrayAsyncCallbackObject = (t1, t2, t3, t4, t5, t6) => { t5(null); return(null); }; MSlaveProxy.AllInstances.EndRequestTopicIAsyncResult = (t1, t2) => result; var client = new SlaveClient(new Uri("http://localhost")); client.RequestTopicAsync("/test", "/rosout", new List <ProtocolInfo> { new ProtocolInfo(ProtocolType.TCPROS) }).Wait(); }
public SlaveNode() { _slaveClient = new SlaveClient(GlobalConfig.Config.MasterIp, GlobalConfig.Config.MasterListenPort); TaskManager = new SlaveTaskManager(); }
protected override void OnStart(string[] args) { #region depreciated //if (MainConfig.CardModeMode != CardModeMode.NoCardNeededDemoMode) //{ // //while (CardManger == null || CardManger?.IsDisposed == true) // //{ // // try // // { // // List<string> Readers = ACR122UManager.GetACR122UReaders(); // // CardManger = new ACR122UManager(Readers[0]); // // } // // catch // // { // // Logger.WriteLog("Error no card reader detected...Please Replugin a compatable cardreader", LoggerWarringLevel.Danger); // // MessageBox.Show("Error no card reader detected...\nPlease Replugin a compatable cardreader and click ok."); // // } // //} // //CardManger.CheckCard = true; // //CardManger.CardDetected += CardDectected; // //CardManger.CardRemoved += CardRemoved; // //CardManger.AcceptedCardScaned += AcceptedCard; // //CardManger.RejectedCardScaned += RejectedCard; // //CardManger.CardStateChanged += CardStateChanged; //} #endregion if (MainConfig.ServerMode != ServerMode.NoServerDemoMode) { while (!TheServerClient.Connected) { try { TheServerClient.Connect(); ResponseInfo <GetMachineGamesReturn, ResponseStatus> Return = TheServerClient.GetMachineGames(MainConfig.MachineGUID); GameConfig = new ServiceJSONGamesConfig(Return.Data); } catch (Exception e) { if (e.Message == "Please provide valid credentials,either user name is invalid or password is invalid") { Logger.WriteLog("Access denied due to incorrect password.", LoggerWarringLevel.Danger); MessageBox.Show("Access denied due to incorrect password. Please correct the password now."); EditServerCredential_Click(this, new EventArgs()); } else { Logger.WriteLog("Error - Server is not responding. Will try again in 20000ms.", LoggerWarringLevel.Danger); Thread.Sleep(20000); } } } } else { GameConfig = new ServiceJSONGamesConfig(); } GameStarter = new GameInstancer(GameConfig); if (MainConfig.StarterMode == GameStartMode.SingleGameStarter == !MenuRunning) { GameMenu.StartMenu(); } GameStarter.GameIsStartingEvent += GameInstancerStartingGame; GameStarter.GameHasStartedEvent += GameInstancerGameHasStarted; GameStarter.GameHasEndedEvent += GameInstancerGameHasEnded; if (MainConfig.CardModeMode != CardModeMode.NoCardNeededDemoMode) { try { NFCReader = new RL8000_NFC(); NFCReader.MifareClassicISO1443ACardDetectedEvent += CardDetected; } catch { const string Error = "\nError - Cannot find card reader.\nPlease replug in the card reader.\nWill try again in 20000ms.\n"; Logger.WriteLog(Error, LoggerWarringLevel.Danger); #if !DEBUG DialogResult Result = MessageBox.Show(Error, "Error", MessageBoxButtons.RetryCancel); if (Result == DialogResult.Cancel) { Application.Exit(); } #endif Thread.Sleep(20000); } } else { try { NFCReader = new RL8000_NFC(); NFCReader.MifareClassicISO1443ACardDetectedEvent += CardDetected; } catch {} } if (MainConfig.StarterMode == GameStartMode.MultiSocketStarterMaster) { while (MasterServer == null) { try { MasterServer = new MasterServer(MainConfig.PortNumber); MasterServer.ShowConsole(); } catch { const string Error = "\nError - Master Server can not open port.\nPlease Check for Port usage or your config file.\nWill try again in 20000ms."; Logger.WriteLog(Error, LoggerWarringLevel.Danger); #if !DEBUG DialogResult Result = MessageBox.Show(Error, "Error", MessageBoxButtons.RetryCancel); if (Result == DialogResult.Cancel) { Application.Exit(); } #endif Thread.Sleep(20000); } } } if (MainConfig.StarterMode == GameStartMode.MultiSocketStarterSlave) { while (SlaveClient == null) { try { SlaveClient = new SlaveClient(MainConfig.MasterStarterMasterLoc, MainConfig.PortNumber); } catch { const string Error = "\nError - Slaves Master Server is not responding.\nPlease Check the server, its endpoint, or your config file.\nWill try again in 20000ms.\n"; Logger.WriteLog(Error, LoggerWarringLevel.Danger); #if !DEBUG DialogResult Result = MessageBox.Show(Error, "Error", MessageBoxButtons.RetryCancel); if (Result == DialogResult.Cancel) { Application.Exit(); } #endif Thread.Sleep(20000); } } } NoIc_GameStarterStopper.ContextMenuStrip = BuildMenu(); NoIc_GameStarterStopper.Visible = true; Logger.WriteLog($"'Arcade Game Start And Stop Service' has Started with the following parameters:\n\tCardModeMode:{MainConfig.CardModeMode}\n\tServerMode:{MainConfig.ServerMode}\n"); }
public SlaveNode() { _slaveClient = new SlaveClient(GlobalConfig.Config.MasterIp, GlobalConfig.Config.MasterListenPort); TaskManager = new SlaveTaskManager((IChannelMessageHandler)_slaveClient); }