private static void InitModules() { Core.User = new User.User(Sdk.Responses); Core.Matcher = new Matcher.Matcher(Sdk.Responses); Core.Sender = new Sender.Sender(Sdk.Responses); Core.Room = new Room.Room(Sdk.Responses); Core.FrameSender = new FrameSender(Sdk.Responses); Core.Socket1 = new Socket(0, false, null); Core.Socket2 = new Socket(1, true, null); Core.Pinger1 = new Pinger(Sdk.Responses, 0, null); Core.Pinger2 = new Pinger(Sdk.Responses, 1, FrameSender); var route1 = new BaseNetUtil[6] { User, Room, Sender, FrameSender.NetUtil1, Pinger1, Matcher }; var route2 = new BaseNetUtil[2] { FrameSender.NetUtil2, Pinger2 }; foreach (var request in route1) { request.BindSocket(Core.Socket1); } foreach (var request in route2) { request.BindSocket(Core.Socket2); } Sdk.UpdateSdk(); }
private static void TestFrames() { #if TRACE_LOG FileName = "Receiver"; LogHelper.WriteToFile("Starting", "Program", FileName, true); FileName = "Sender"; LogHelper.WriteToFile("Starting", "Program", FileName, true); #endif FrameSender sender = new FrameSender(); ulong counter = 0; while (true) { FileName = "Sender"; #if TRACE_LOG LogHelper.WriteToFile("Prepare to sending packet.", "Program", FileName, true); #endif List <Packet> sendPackets = new List <Packet>(); while (sendPackets.Count == 0) //for (int i = 0; i < 1; i++) { //Packet p = GetPacketB(); Packet p = RandomPacket(); if (sender.ProcessPacket(p)) { sendPackets.Add(p); } } byte[] data = sender.Send(); FileName = "Receiver"; FrameReceiver receiver = new FrameReceiver(); #if TRACE_LOG LogHelper.WriteToFile("Prepare to receive packet.", "Program", FileName, true); #endif List <IPacket> readPackets = receiver.Receive(data); Debug.Assert(sendPackets.Count == readPackets.Count); for (int i = 0; i < sendPackets.Count; i++) { IPacket itemA = sendPackets[i]; IPacket itemB = readPackets[i]; Debug.Assert(itemA.Equals(itemB)); } Console.WriteLine(counter); counter++; } }
public static bool _RemoteIsBigEndian = true; //PC = Little-Endian, CPU = Big-Endian //public static Int16 _allFrameCounterStatic = 0; //frame index -> at > ca 65000 restart @0 //public static Int64 _allFrameCounterTotal = 0; //all frames in total since tool start #endregion #region construktor public FrameRawData(Client _client, byte[] data, FrameSender FS) { //TODO: catch ursache beheben(client == null) try { //_allFrameCounterStatic++; //_allFrameCounterTotal++; this.client = _client; //darĂ¼ber kann ein Frame Objekt sich selbst versenden TimeCreated = DateTime.Now; LastSendDateTime = DateTime.Now; frameSender = FS; ///#### "make new frame to send it later on" #### if (frameSender.Equals(FrameSender.SEND)) { // ++ send Frame to Remote ++ //data is only payload, no FrameHeader //Index_tmp = _allFrameCounterStatic; Index_tmp = client.CountSendFrames; //header = new FrameHeader(client.CountSendFrames); (***) header = new FrameHeader(Index_tmp); FramePayloadByte = data; if (_RemoteIsBigEndian) { FramePayloadByte = changeEndian(FramePayloadByte); } } ///#### "make new frame from rcv UDP Frame" #### else if (frameSender.Equals(FrameSender.RCVE)) { // ++ rcv Frame from Remote ++ //data includes FrameHeader header = new FrameHeader(data, out FramePayloadByte); } } catch (Exception e) { System.IO.File.AppendAllText(@"C:\Users\alex\Desktop\DbgAhGUI_frames.txt", "Exp: " + e.Message + Environment.NewLine); } }
public Pinger(Responses responses, int id, FrameSender frameSender) : base(responses) { this.Id = id; this.FrameSender = frameSender; }
public Pinger(BstCallbacks bstCallbacks, int id, FrameSender frameSender) : base(bstCallbacks) { this.Id = id; this.FrameSender = frameSender; }