static void Main(string[] args) { Console.Title = "Cable Cloud"; ConnectionsTable.init(); SendingManager.init(); initListeningOnSockets(); }
private static void RealStart(CloudPortsRow row) { int outputPort = row.getOutPort(); String nodeName = row.getNodeName(); InSocket inputSocket = new InSocket(row.getInPort(), nodeName); OutSocket outputSocket = new OutSocket(outputPort, nodeName); while (true) { inputSocket.ListenForConnection(); outputSocket.ListenForConnection(); SendingManager.addOutSocket(outputSocket); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Connected with node: " + nodeName); try { inputSocket.ListenForIncomingData(); } catch (SocketException e) { SendingManager.removeSocket(outputSocket); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Node " + nodeName + " disconnected."); } } }
public void ListenForIncomingData() { byte[] bytes; while (true) { bytes = new byte[4]; int inputSize = ReceiveInputSize(); byte[] receivedData = receiveData(inputSize); int sourcePort = GetSourcePort(receivedData); Console.WriteLine("Recieved from node " + nodeName + "From port " + sourcePort.ToString()); SendingManager.Send(receivedData, nodeName, sourcePort); } }
public void ListenForIncomingData() { byte[] bytes; while (true) { bytes = new byte[4]; int inputSize = ReceiveInputSize(); byte[] receivedData = receiveData(inputSize); int sourcePort = GetSourcePort(receivedData); string timeStamp = CableCloud.GetTimeStamp(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine(timeStamp + " | Recieved from node " + nodeName + " from port " + sourcePort.ToString()); SendingManager.Send(receivedData, nodeName, sourcePort); } }