void HandleServerHopping(ServerPingHopperPacket packet) { // TODO... not correct ServerPingHopperPacket hopper = packet as ServerPingHopperPacket; string name = Assembly.GetCallingAssembly().GetName().Name; hopper.Stamp(name + " received"); Send(packet); }
void HandleServerHopping(ServerPingHopperPacket packet) { ServerConnectionHeader gatewayHeader = (ServerConnectionHeader)IntrepidSerialize.TakeFromPool(PacketType.ServerConnectionHeader); gatewayHeader.connectionId = nextConnectionId; socket.Send(gatewayHeader); ServerPingHopperPacket hopper = packet as ServerPingHopperPacket; string name = Assembly.GetCallingAssembly().GetName().Name; hopper.Stamp(name + " received"); Send(packet); }
void HandleNormalPackets(Queue <BasePacket> listOfPackets) { foreach (var packet in listOfPackets) { numPacketsReceived++; // normal processing EntityPacket ep = packet as EntityPacket; if (ep != null) { //entityId = ep.entityId; int tempEntityId = ep.entityId; if (entityId == tempEntityId) { Console.Write("This entity packet updated {0}\n", tempEntityId); } else { Console.Write("Entity update packet {0}\n", tempEntityId); } entityId = tempEntityId; continue; } KeepAlive ka = packet as KeepAlive; if (ka != null) { KeepAliveResponse kar = (KeepAliveResponse)IntrepidSerialize.TakeFromPool(PacketType.KeepAliveResponse); socket.Send(kar); } if (packet is ServerPingHopperPacket) { ServerPingHopperPacket hopper = packet as ServerPingHopperPacket; hopper.Stamp("client end"); hopper.PrintList(); } if (packet.PacketType == PacketType.DataBlob) { HandleBlobData(packet as DataBlob); } } foreach (var packet in listOfPackets) { if (packet.PacketType != PacketType.DataBlob)// tyhese need special handling { IntrepidSerialize.ReturnToPool(packet); } } }
private static void Main(string[] args) { CommonLibrary.Parser.ParseCommandLine(args); Int64 applicationId = 1234;/*CommonLibrary.Parser.ApplicationId; * if (applicationId == 0) * { * applicationId = Network.Utils.GetIPBasedApplicationId(); * }*/ float sleepTime = 1000.0f / (float)CommonLibrary.Parser.FPS; string ipAddr = CommonLibrary.Parser.ipAddr; //ipAddr = "192.168.30.214"; ipAddr = "192.168.0.28"; Console.WriteLine("Client talking to Server."); Console.WriteLine(" Press L to login (auto login is set)."); Console.WriteLine(" Press P to update player position."); Console.WriteLine(" Press K to change to main player position."); Console.WriteLine(" ** application id = {0} **", applicationId); Console.WriteLine(" Press esc to update player position.\n\n"); ushort port = 11000; Testing.ClientController testClient = new Testing.ClientController(ipAddr, port, applicationId); testClient.OnImageReceived += ImageReceived; ConsoleKey key; do { while (!Console.KeyAvailable) { Thread.Sleep(20); testClient.Update(); } key = Console.ReadKey(true).Key; if (key == ConsoleKey.L) { LoginCredentials cred = (LoginCredentials)IntrepidSerialize.TakeFromPool(PacketType.LoginCredentials); cred.password.Copy("password"); cred.playerName.Copy("mickey"); testClient.Send(cred); Console.WriteLine("login sent."); } if (key == ConsoleKey.D4) { RenderSettings settings = (RenderSettings)IntrepidSerialize.TakeFromPool(PacketType.RenderSettings); settings.screenWidth = 1280; settings.screenHeight = 720; settings.screenFormat = RenderSettings.RenderFormat.RGBA; settings.maxFPS = 20; testClient.Send(settings); Console.WriteLine("settings sent."); } if (key == ConsoleKey.D5) { RenderSettings settings = (RenderSettings)IntrepidSerialize.TakeFromPool(PacketType.RenderSettings); settings.screenWidth = 1280; settings.screenHeight = 720; settings.screenFormat = RenderSettings.RenderFormat.RGBA; settings.maxFPS = 4; testClient.Send(settings); Console.WriteLine("settings sent."); } if (key == ConsoleKey.D6) { RenderSettings settings = (RenderSettings)IntrepidSerialize.TakeFromPool(PacketType.RenderSettings); settings.screenWidth = 1280; settings.screenHeight = 720; settings.screenFormat = RenderSettings.RenderFormat.RGBA; settings.maxFPS = -1; testClient.Send(settings); Console.WriteLine("settings sent."); } if (key == ConsoleKey.P) { WorldEntityPacket we = (WorldEntityPacket)IntrepidSerialize.TakeFromPool(PacketType.WorldEntity); we.entityId = 1024; we.position.Set(new Vector3(10, 20, 30)); we.rotation.Set(new Vector3(10, 20, 30)); testClient.Send(we); Console.WriteLine("position sent."); } if (key == ConsoleKey.K) { WorldEntityPacket we = (WorldEntityPacket)IntrepidSerialize.TakeFromPool(PacketType.WorldEntity); we.entityId = 1024; we.position.Set(new Vector3(44, 0.20f, 21)); we.rotation.Set(new Vector3(5, 25, 30)); testClient.Send(we); Console.WriteLine("position sent."); } if (key == ConsoleKey.M) { Console.WriteLine("Major list of crap to send"); var test = new Packets.TestPacket(); Packets.TestDataBlob blob1 = new Packets.TestDataBlob(1, 2); Packets.TestDataBlob blob2 = new Packets.TestDataBlob(3, 4); Packets.TestDataBlob blob3 = new Packets.TestDataBlob(5, 6); test.listOfBlobs.listOfSerializableItems.Add(blob1); test.listOfBlobs.listOfSerializableItems.Add(blob2); test.listOfBlobs.listOfSerializableItems.Add(blob3); testClient.Send(test); } if (key == ConsoleKey.T) { Console.WriteLine("Setting up the hopper"); ServerPingHopperPacket hopper = (ServerPingHopperPacket)IntrepidSerialize.TakeFromPool(PacketType.ServerPingHopper); hopper.Stamp("client start"); testClient.Send(hopper); } if (key == ConsoleKey.B) { Console.WriteLine("Sending blob"); //DataBlob blob = new DataBlob(); DataBlob blob = (DataBlob)IntrepidSerialize.TakeFromPool(PacketType.DataBlob); int size = 800; byte[] data = new byte[size]; for (int i = 0; i < size; i++) { data[i] = (byte)i; } blob.Prep(data, size); testClient.Send(blob); } if (key == ConsoleKey.A) { int size = 8000; byte[] data = new byte[size]; for (int i = 0; i < size; i++) { data[i] = (byte)i; } Utils.DatablobAccumulator acc = new Utils.DatablobAccumulator(); List <DataBlob> blobs = acc.PrepToSendRawData(data, size); foreach (var blob in blobs) { testClient.Send(blob); } } if (key == ConsoleKey.S) { int size = 2000000; byte[] data = new byte[size]; for (int i = 0; i < size; i++) { data[i] = (byte)i; } Utils.DatablobAccumulator acc = new Utils.DatablobAccumulator(); List <DataBlob> blobs = acc.PrepToSendRawData(data, size); var Timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds(); Console.WriteLine(Timestamp); foreach (var blob in blobs) { testClient.Send(blob); } } if (key == ConsoleKey.R) { RequestPacket request = (RequestPacket)IntrepidSerialize.TakeFromPool(PacketType.RequestPacket); request.type = RequestPacket.RequestType.RequestRenderFrame; var Timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds(); //Console.WriteLine("request start {0} ms", Timestamp); testClient.startTimeMilliseconds = Timestamp; testClient.Send(request); } } while (key != ConsoleKey.Escape); testClient.Close(); }
static void Main(string[] args) { CommonLibrary.Parser.ParseCommandLine(args); Int64 applicationId = CommonLibrary.Parser.ApplicationId; if (applicationId == 0) { applicationId = Network.Utils.GetIPBasedApplicationId(); } float sleepTime = 1000.0f / (float)CommonLibrary.Parser.FPS; string ipAddr = CommonLibrary.Parser.ipAddr; Console.WriteLine("Client talking to Gateway."); Console.WriteLine(" Press L to login (auto login is set)."); Console.WriteLine(" Press P to update player position."); Console.WriteLine(" Press K to change to main player position."); Console.WriteLine(" ** application id = {0} **", applicationId); Console.WriteLine(" Press esc to update player position.\n\n"); ushort port = 11000; TestClientToGatewayController testClient = new TestClientToGatewayController(ipAddr, port, applicationId); ConsoleKey key; do { while (!Console.KeyAvailable) { } key = Console.ReadKey(true).Key; if (key == ConsoleKey.L) { LoginCredentials cred = (LoginCredentials)IntrepidSerialize.TakeFromPool(PacketType.LoginCredentials); cred.password.Copy("password"); cred.playerName.Copy("mickey"); testClient.Send(cred); Console.WriteLine("login sent."); } if (key == ConsoleKey.P) { WorldEntityPacket we = (WorldEntityPacket)IntrepidSerialize.TakeFromPool(PacketType.WorldEntity); we.entityId = 1024; we.position.Set(new Vector3(10, 20, 30)); we.rotation.Set(new Vector3(10, 20, 30)); testClient.Send(we); Console.WriteLine("position sent."); } if (key == ConsoleKey.K) { WorldEntityPacket we = (WorldEntityPacket)IntrepidSerialize.TakeFromPool(PacketType.WorldEntity); we.entityId = 1024; we.position.Set(new Vector3(44, 0.20f, 21)); we.rotation.Set(new Vector3(5, 25, 30)); testClient.Send(we); Console.WriteLine("position sent."); } if (key == ConsoleKey.M) { Console.WriteLine("Major list of crap to send"); var test = new Packets.TestPacket(); Packets.TestDataBlob blob1 = new Packets.TestDataBlob(1, 2); Packets.TestDataBlob blob2 = new Packets.TestDataBlob(3, 4); Packets.TestDataBlob blob3 = new Packets.TestDataBlob(5, 6); test.listOfBlobs.listOfSerializableItems.Add(blob1); test.listOfBlobs.listOfSerializableItems.Add(blob2); test.listOfBlobs.listOfSerializableItems.Add(blob3); testClient.Send(test); } if (key == ConsoleKey.T) { Console.WriteLine("Sending round trip"); ServerPingHopperPacket hopper = (ServerPingHopperPacket)IntrepidSerialize.TakeFromPool(PacketType.ServerPingHopper); hopper.Stamp("client start"); testClient.Send(hopper); } } while (key != ConsoleKey.Escape); testClient.Close(); }
void HandleNormalPackets(Queue <BasePacket> listOfPackets) { foreach (var packet in listOfPackets) { //Console.WriteLine("normal packet received {0} .. isLoggedIn = true", packet.PacketType); numPacketsReceived++; // normal processing if (packet is PlayerFullPacket && localPlayer.entityId == 0) { localPlayer.entityId = (packet as PlayerFullPacket).entityId; } /* ServerTick st = packet as ServerTick; * if(st != null) * { * Console.WriteLine("server tick {0}", st.TickCount); * * continue; * }*/ KeepAlive ka = packet as KeepAlive; if (ka != null) { KeepAliveResponse kar = (KeepAliveResponse)IntrepidSerialize.TakeFromPool(PacketType.KeepAliveResponse); socket.Send(kar); } if (packet is ServerPingHopperPacket) { ServerPingHopperPacket hopper = packet as ServerPingHopperPacket; hopper.Stamp("client end"); hopper.PrintList(); } if (packet is WorldEntityPacket) { WorldEntityPacket wep = packet as WorldEntityPacket; if (localPlayer.entityId == wep.entityId) { localPlayer.position = wep.position.Get(); localPlayer.rotation = wep.rotation.Get(); } } EntityPacket ep = packet as EntityPacket; if (ep != null) { //entityId = ep.entityId; int tempEntityId = ep.entityId; if (localPlayer.entityId == tempEntityId) { Console.Write("This entity packet updated {0}\n", tempEntityId); } /* else * { * Console.Write("Entity update packet {0}\n", tempEntityId); * }*/ continue; } // Console.WriteLine("normal packet received {0}", packet.PacketType); IntrepidSerialize.ReturnToPool(packet); } }