private void SlotsLocked(CommandLibrary.Command command, Socket handler) { command.destinationId = self.ReturnName() + ":CC"; command.sourceId = LRMName; using (var stream = new NetworkStream(handler)) { BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(stream, command); stream.Flush(); stream.Close(); } self.mainWindow.Invoke(new Action(() => self.Logs += DateTime.UtcNow.ToString("HH:mm:ss.fff") + $" >> LRM >> 'Subcarrier Slots Lock Request' sent to {command.destinationId}" + Environment.NewLine)); }
public void Reader() { string[] split = self.ReturnName().Split(new char[] { ':' }); string join = string.Join("", split); var path = System.Configuration.ConfigurationManager.AppSettings[join + "RC"]; XmlTextReader reader = new XmlTextReader(path); int linkID; string Object1; string Object2; int portObject1; int portObject2; int length; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "link") { linkID = Int32.Parse(reader.GetAttribute("id")); Object1 = reader.GetAttribute("o1"); Object2 = reader.GetAttribute("o2"); portObject1 = Int32.Parse(reader.GetAttribute("p1")); portObject2 = Int32.Parse(reader.GetAttribute("p2")); length = Int32.Parse(reader.GetAttribute("len")); CommandLibrary.Link l = new CommandLibrary.Link(linkID, Object1, Object2, portObject1, portObject2, length); l.usedSlots = new List <int>(); links.Add(l); } break; case XmlNodeType.Text: Console.WriteLine(reader.Value); break; case XmlNodeType.EndElement: if (reader.Name == "link") { Console.WriteLine("End mark reached"); } break; } } }
public LinkResourceManager(string lrmId, int lrmPort, Subnetwork selfSub) { LRMName = lrmId; self = selfSub; subnetworkName = self.ReturnName(); linkList = new List <CommandLibrary.Link>(); Reader(); LRMIPEP = new IPEndPoint(IPAddress.Parse(host), lrmPort); serverIPEP = new IPEndPoint(IPAddress.Parse(host), 50000); socket = new Socket(SocketType.Stream, ProtocolType.Tcp); socket.Bind(LRMIPEP); socket.BeginConnect(serverIPEP, new AsyncCallback(ConnectCallback), socket); Console.WriteLine("finish"); }
private void OXCCleared(CommandLibrary.Command command, Socket handler) { CommandLibrary.Command response = new CommandLibrary.Command("OXC Cleared"); Connection conn = connectionList.Find(x => x.connectionId == command.connectionId); if (conn != null) { connectionList.Remove(conn); } response.connectionId = command.connectionId; response.deletedLinkId = command.deletedLinkId; string[] s = self.ReturnName().Split(':'); response.destinationId = s[0] + ":NCC"; using (var stream = new NetworkStream(handler)) { BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(stream, response); stream.Flush(); stream.Close(); } }