public byte[] update() { if (client.IsAttentionRequired) // when server response msg NEWLY arrived { if (sub == null) { if (client.TargetPort < 1) { Debug.Log("no publisher found"); client.sendMyInfo(); return(null); } sub = new DRSocket(client.ClientName); Debug.Log("connectig to : " + client.TargetPort); sub.setMyInfo(false, client.MyIp, client.TargetNodeName); sub.connectToServer(client.TargetIP, client.TargetPort); sub.sendMyInfo(); client.IsAttentionRequired = false; } if (sub.isConnected()) { okToSubscribe = true; } return(null); } else if (okToSubscribe) // server reponse msg is already porcessed and connected to publisher { Debug.Log("here 1"); if (sub.IsNewlyReceived) { Debug.Log("here 2"); sub.IsNewlyReceived = false; byte[] bMsg = sub.getRecentData(); return(bMsg); } else { return(null); } } else // when server response msg not arrived { if (sub == null) { return(null); } if (!sub.isConnected()) { if (!sub.isConnected()) { okToSubscribe = false; } client.TargetPort = -1; client.IsAttentionRequired = true; sub = null; } return(null); } }
private void constructorHelper(string name, string serverIP, int serverPort) { isConnected = false; okToPublish = false; updateRate = 0; client = new DRSocket(name); client.IsPublisher = true; client.connectToServer(serverIP, serverPort); isConnected = client.IsSocketReady; client.sendMyInfo(); while (!client.IsAttentionRequired) { if (serverCheckCount > 60 * 5) { Debug.Log("is DRMonitor there?"); throw new Exception(); } Debug.Log(client.IsAttentionRequired); serverCheckCount++; Thread.Sleep(20); } okToPublish = true; Debug.Log("port to pub: " + client.TopicPort); openTopicRegistrationDesk(); }
private void connMethod() { while (!isConnected) { client.sendMyInfo(); isConnected = client.IsSocketReady; Debug.Log("is DRMonitor Running?"); knockServerCounter++; if (knockServerCounter > 10) { client.connectToServer(serverIP, serverPort); knockServerCounter = 0; } Thread.Sleep((int)1000.0 / 30); } }
public DRSubscriber(string name, string serverIP, int serverPort, string targetPubName) { this.serverIP = serverIP; this.serverPort = serverPort; okToSubscribe = false; isConnected = false; client = new DRSocket(name); client.connectToServer(serverIP, serverPort); isConnected = client.IsSocketReady; client.setMyInfo(false, "127.0.0.1", targetPubName); client.sendMyInfo(); Thread connThread = new Thread(new ThreadStart(connMethod)); connThread.Start(); }
private void constructorHelper(string name, string serverIP, int serverPort) { this.serverIP = serverIP; this.serverPort = serverPort; isConnected = false; okToPublish = false; updateRate = 0; client = new DRSocket(name); client.IsPublisher = true; client.connectToServer(serverIP, serverPort); isConnected = client.IsSocketReady; Thread connThread = new Thread(new ThreadStart(connMethod)); connThread.Start(); }
private void connMethod() { while (!client.IsAttentionRequired) { client.sendMyInfo(); Debug.Log("is DRMonitor there?"); isConnected = client.IsSocketReady; Thread.Sleep(500); knockServerCounter++; if (knockServerCounter > 10) { client.connectToServer(serverIP, serverPort); knockServerCounter = 0; } } okToPublish = true; Debug.Log("port to pub: " + client.TopicPort); openTopicRegistrationDesk(); Debug.Log("after regi desk"); }
public DRSubscriber(string name, string serverIP, int serverPort, string targetPubName) { okToSubscribe = false; isConnected = false; client = new DRSocket(name); client.connectToServer(serverIP, serverPort); isConnected = client.IsSocketReady; client.setMyInfo(false, "127.0.0.1", targetPubName); client.sendMyInfo(); while (!client.IsAttentionRequired) { if (serverCheckCount > 60 * 5) { Debug.Log("is DRMonitor there?"); QuitGame(); } Debug.Log(client.IsAttentionRequired); serverCheckCount++; Thread.Sleep(100); } }
public byte[] update() { if (client.IsAttentionRequired) { if (sub == null) { if (client.TargetPort == -1) { Debug.Log("no publisher found"); QuitGame(); return(null); } sub = new DRSocket(client.ClientName); Debug.Log("connectig to : " + client.TargetPort); sub.setMyInfo(false, client.MyIp, client.TargetNodeName); sub.connectToServer(client.MyIp, client.TargetPort); sub.sendMyInfo(); } client.IsAttentionRequired = false; if (sub.isConnected()) { okToSubscribe = true; } } if (!okToSubscribe) { return(null); } if (sub.IsNewlyReceived && okToSubscribe) { sub.IsNewlyReceived = false; byte[] bMsg = sub.getRecentData(); return(bMsg); } else { return(null); } }