public ZKHelper() { fHelper = new FileHelper(); netDet = fHelper.readNetworkDetails(); FileHelper.writeToLog("\r\n\n" + "Test Text"); }
public void PlayerJoinRoom(int PlayerConnectionID, Vector3 Position) { Player player = PlayerManager.Instance.GetPlayer(PlayerConnectionID); player.OnPlayerChangeRooms(this); if (!PlayerConnectionIDsInRoom.Contains(PlayerConnectionID)) { PlayerConnectionIDsInRoom.Add(PlayerConnectionID); } if (NetworkDetails.IsLocalConnectionID(PlayerConnectionID)) { for (int i = 0; i < PlayerConnectionIDsInRoom.Count; i++) { PlayerManager.Instance.GetPlayer(PlayerConnectionIDsInRoom[i]).SetIsVisible(true); } } #if SERVER NetworkPacketSender.SendRoomData(PlayerConnectionID, RoomIndex); NetworkPacketSender.AddPlayerToRoom(PlayerConnectionID, this, Position); #endif player.transform.position = Position; player.SetIsVisible(true); }
public async Task RefreshAysnc() { var address = GetIPV4Address(); await Task.Delay(1); var profiles = NetworkInformation.GetConnectionProfiles(); var connections = new List <NetworkDetails>(); var icp = NetworkInformation.GetInternetConnectionProfile(); if (icp != null && icp.NetworkAdapter != null) { var settings = icp.GetNetworkConnectivityLevel(); var hostnames = NetworkInformation.GetHostNames().Where( hn => hn.IPInformation?.NetworkAdapter != null && hn.IPInformation.NetworkAdapter.NetworkAdapterId == icp.NetworkAdapter.NetworkAdapterId); var ipV4hostName = hostnames.Where(hst => hst.Type == Windows.Networking.HostNameType.Ipv4).FirstOrDefault(); if (ipV4hostName != null) { var network = new NetworkDetails() { Name = icp.ProfileName, IPAddress = ipV4hostName.CanonicalName, }; switch (icp.GetNetworkConnectivityLevel()) { case NetworkConnectivityLevel.ConstrainedInternetAccess: network.Connectivity = "Limited Internet"; break; case NetworkConnectivityLevel.InternetAccess: network.Connectivity = "Internet"; break; case NetworkConnectivityLevel.LocalAccess: network.Connectivity = "Local Only"; break; case NetworkConnectivityLevel.None: network.Connectivity = "None"; break; } connections.Add(network); } } LagoVista.Core.PlatformSupport.Services.DispatcherServices.Invoke(() => { _allConnections.Clear(); foreach (var network in connections) { _allConnections.Add(network); } }); }
public void TestParseIpv6Ranges() { var parser = new NetworkParser(); var expected = new NetworkDetails { BroadcastAddress = IPAddress.Parse("2001:db8:85a3::8a2e:370:733f"), NetworkAddress = IPAddress.Parse("2001:db8:85a3::8a2e:370:7330"), SubNetMask = IPAddress.Parse("ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff0"), UsableEndAddress = IPAddress.Parse("2001:db8:85a3::8a2e:370:733e"), UsableStartAddress = IPAddress.Parse("2001:db8:85a3::8a2e:370:7331"), MaxHosts = 16, MaxUsableHosts = 14, }; var actual = parser.ParseRange("2001:0db8:85a3::8a2e:0370:7334 /124"); AssertEquality(expected, actual); Assert.IsTrue(actual.IsInRange(IPAddress.Parse("2001:db8:85a3::8a2e:370:733f"))); Assert.IsFalse(actual.IsInRangeUsable(IPAddress.Parse("2001:db8:85a3::8a2e:370:733f"))); Assert.IsTrue(actual.IsInRange(IPAddress.Parse("2001:db8:85a3::8a2e:370:733e"))); Assert.IsTrue(actual.IsInRangeUsable(IPAddress.Parse("2001:db8:85a3::8a2e:370:733e"))); Assert.IsFalse(actual.IsInRange(IPAddress.Parse("2001:db8:85a3::8a2e:370:7340"))); Assert.IsFalse(actual.IsInRangeUsable(IPAddress.Parse("2001:db8:85a3::8a2e:370:7340"))); Assert.IsTrue(actual.IsInRange(IPAddress.Parse("2001:db8:85a3::8a2e:370:733A"))); Assert.IsTrue(actual.IsInRangeUsable(IPAddress.Parse("2001:db8:85a3::8a2e:370:733A"))); Assert.IsFalse(actual.IsInRange(IPAddress.Parse("2001:db8:85a3::8a2e:370:732F"))); Assert.IsFalse(actual.IsInRangeUsable(IPAddress.Parse("2001:db8:85a3::8a2e:370:732f"))); }
public void TestParseIpv4Ranges() { var parser = new NetworkParser(); var expected = new NetworkDetails { BroadcastAddress = IPAddress.Parse("192.168.1.7"), NetworkAddress = IPAddress.Parse("192.168.1.0"), SubNetMask = IPAddress.Parse("255.255.255.248"), UsableStartAddress = IPAddress.Parse("192.168.1.1"), UsableEndAddress = IPAddress.Parse("192.168.1.6"), MaxHosts = 8, MaxUsableHosts = 6 }; var actual = parser.ParseRange("192.168.1.5 /29"); AssertEquality(expected, actual); Assert.IsTrue(actual.IsInRange(IPAddress.Parse("192.168.1.5"))); Assert.IsTrue(actual.IsInRangeUsable(IPAddress.Parse("192.168.1.5"))); Assert.IsTrue(actual.IsInRange(IPAddress.Parse("192.168.1.0"))); Assert.IsFalse(actual.IsInRangeUsable(IPAddress.Parse("192.168.1.0"))); Assert.IsFalse(actual.IsInRange(IPAddress.Parse("192.168.1.25"))); Assert.IsFalse(actual.IsInRangeUsable(IPAddress.Parse("192.168.1.25"))); }
public OrcHelper() { netDet = fHelper.readNetworkDetails(); if (orcConn == null) { createConnection(); } }
public static void SendToServerOnly(NetworkPacket Packet, QosType QualityOfServiceType) { Packet.SetPacketTarget(PacketTargets.ServerOnly); #if SERVER NetworkPacketReader.ReadPacket(Packet, NetworkDetails.GetLocalConnectionID(), true); #else ClientNetworkManager.Instance.SendPacketToServer(Packet, QualityOfServiceType); #endif }
public void WriteNetworkDetails(NetworkDetails nDet) { File.WriteAllText("orcl.txt", nDet.IP_DB + "\r\n" + nDet.PORT_DB + "\r\n" + nDet.SID + "\r\n" + nDet.DBNAME + "\r\n" + nDet.DBPASS + "\r\n" + nDet.IP_AM + "\r\n" + nDet.PORT_AM + "\r\n" + nDet.XCODE + "\r\n" + nDet.YCODE + "\r\n" + nDet.MCODE); }
public Player SpawnPlayer(int ConnectionID) { #if SERVER return(SpawnServerPlayer(ConnectionID)); #else if (ConnectionID == NetworkDetails.GetLocalConnectionID()) { return(SpawnControllerablePlayer(ConnectionID)); } return(SpawnNormalPlayer(ConnectionID)); #endif }
public static void SendPacketToAllPlayers(NetworkPacket Packet, QosType QualityOfServiceType, bool ShouldServerReadPacket) { #if SERVER if (ShouldServerReadPacket) { NetworkPacketReader.ReadPacket(Packet, NetworkDetails.GetLocalConnectionID(), true); } NetworkManager.Instance.SendPacketToAllClients(Packet, NetworkManager.Instance.GetChannel(QualityOfServiceType)); #else Packet.SetPacketTarget(PacketTargets.RelayToAllClients); ClientNetworkManager.Instance.SendPacketToServer(Packet, QualityOfServiceType); #endif }
public DataTable GetUserConnections(DO_Networks objNetwork, NetworkDetails flag) { DataTable dt = new DataTable(); conn = co.GetConnection(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand("Scrl_AddEditDelMyNetworks", conn); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.Add("@intRegistrationId", SqlDbType.Int).Value = objNetwork.RegistrationId; da.SelectCommand.Parameters.Add("@FlagNo", SqlDbType.Int).Value = flag; da.Fill(dt); co.CloseConnection(conn); return(dt); }
public SettingsForm() { InitializeComponent(); label11.Visible = false; fHelper = new FileHelper(); NetworkDetails netDet = fHelper.readNetworkDetails(); text_db_ip.Text = netDet.IP_DB; text_db_port.Text = netDet.PORT_DB; text_sid.Text = netDet.SID; text_db_name.Text = netDet.DBNAME; text_db_pass.Text = netDet.DBPASS; text_m_ip.Text = netDet.IP_AM; text_m_port.Text = netDet.PORT_AM; text_comp_code.Text = netDet.XCODE.ToString(); text_branch_code.Text = netDet.YCODE.ToString(); text_machine_code.Text = netDet.MCODE.ToString(); }
public void PlayerLeaveRoom(int PlayerConnectionID) { #if SERVER NetworkPacketSender.RemovePlayerFromRoom(PlayerConnectionID, this); #endif PlayerConnectionIDsInRoom.Remove(PlayerConnectionID); if (NetworkDetails.IsLocalConnectionID(PlayerConnectionID)) { for (int i = 0; i < PlayerConnectionIDsInRoom.Count; i++) { PlayerManager.Instance.GetPlayer(PlayerConnectionIDsInRoom[i]).SetIsVisible(false); } } else { PlayerManager.Instance.GetPlayer(PlayerConnectionID).SetIsVisible(false); } }
public DataTable GetSANotifications(int CurrentPage, int CurrentPageSize, NetworkDetails flag) { DataTable dt = new DataTable(); conn = co.GetConnection(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand("Scrl_AddEditDelMyNetworks", conn); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.Add("@FlagNo", SqlDbType.Int).Value = flag; da.SelectCommand.Parameters.Add("@Currentpage", SqlDbType.Int).Value = CurrentPage; da.SelectCommand.Parameters.Add("@pagesize", SqlDbType.Int).Value = CurrentPageSize; da.Fill(dt); co.CloseConnection(conn); return(dt); }
public static void RelayPacketToPlayersInRoom(NetworkPacket Packet, Room TargetRoom, QosType QualityOfServiceType, bool ShouldServerReadPacket) { #if SERVER if (ShouldServerReadPacket) { NetworkPacketReader.ReadPacket(Packet, NetworkDetails.GetLocalConnectionID(), true); } Packet.SetIsTargetRoom(false); int[] PlayerConnectionIDs = TargetRoom.GetPlayersInRoom(); for (int i = 0; i < PlayerConnectionIDs.Length; i++) { Packet.SetPacketTarget(PlayerConnectionIDs[i]); NetworkManager.Instance.SendPacketToClient(Packet, QualityOfServiceType); } #else Packet.SetPacketTarget(TargetRoom.GetRoomIndex()); Packet.SetIsTargetRoom(true); ClientNetworkManager.Instance.SendPacketToServer(Packet, QualityOfServiceType); #endif }
public DataTable GetDatatable(DO_Networks objNetwork, NetworkDetails flag) { DataTable dt = new DataTable(); conn = co.GetConnection(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand("Scrl_AddEditDelMyNetworks", conn); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.Add("@FlagNo", SqlDbType.Int).Value = flag; da.SelectCommand.Parameters.Add("@intRegistrationId", SqlDbType.Int).Value = objNetwork.RegistrationId; da.SelectCommand.Parameters.Add("@PageSize", SqlDbType.Int).Value = objNetwork.CurrentPageSize; da.SelectCommand.Parameters.Add("@Currentpage", SqlDbType.Int).Value = objNetwork.CurrentPage; da.SelectCommand.Parameters.Add("@NotificationDate", SqlDbType.VarChar, 20).Value = objNetwork.NotificationDate; da.Fill(dt); co.CloseConnection(conn); return(dt); }
public NetworkDetails readNetworkDetails() { var textLines = File.ReadAllLines("orcl.txt"); string[] dataArray = textLines; NetworkDetails networkDetails = new NetworkDetails(); networkDetails.IP_DB = dataArray[0]; networkDetails.PORT_DB = dataArray[1]; networkDetails.SID = dataArray[2]; networkDetails.DBNAME = dataArray[3]; networkDetails.DBPASS = dataArray[4]; networkDetails.IP_AM = dataArray[5]; networkDetails.PORT_AM = dataArray[6]; networkDetails.XCODE = int.Parse(dataArray[7]); networkDetails.YCODE = int.Parse(dataArray[8]); networkDetails.MCODE = int.Parse(dataArray[9]); return(networkDetails); }
private void btn_save_Click(object sender, EventArgs e) { string db_ip = text_db_ip.Text, db_port = text_db_port.Text, db_sid = text_sid.Text, db_name = text_db_name.Text, db_pass = text_db_pass.Text, m_ip = text_m_ip.Text, m_port = text_m_port.Text, comp_code = text_comp_code.Text, branch_code = text_branch_code.Text, machine_code = text_machine_code.Text; if (db_ip.Equals("") || db_port.Equals("") || db_sid.Equals("") || db_name.Equals("") || db_pass.Equals("") || m_ip.Equals("") || m_port.Equals("") || comp_code.Equals("") || branch_code.Equals("") || machine_code.Equals("")) { label11.Visible = true; } else { NetworkDetails nDet = new NetworkDetails(); nDet.IP_DB = db_ip; nDet.PORT_DB = db_port; nDet.SID = db_sid; nDet.DBNAME = db_name; nDet.DBPASS = db_pass; nDet.IP_AM = m_ip; nDet.PORT_AM = m_port; nDet.XCODE = int.Parse(comp_code); nDet.YCODE = int.Parse(branch_code); nDet.MCODE = int.Parse(machine_code); fHelper.WriteNetworkDetails(nDet); label11.Visible = false; this.Close(); } }
public static void ReadPacket(NetworkPacket Packet, int SenderConnectionID, bool isServerReading) { switch (Packet.PacketHeader) { case NetworkPacketHeader.ConnectionID: { int LocalConnectionID = BitConverter.ToInt32(Packet.GetPacketData(), 0); NetworkDetails.SetLocalConnectionID(LocalConnectionID); NetworkPacketSender.SendPlayerReady(LocalConnectionID); } break; case NetworkPacketHeader.RequestConnectionID: { NetworkPacket ConnectionIDPacket = ScriptableObject.CreateInstance <NetworkPacket>(); ConnectionIDPacket.SetPacketTarget(SenderConnectionID); ConnectionIDPacket.PacketHeader = NetworkPacketHeader.ConnectionID; ConnectionIDPacket.SetPacketData(BitConverter.GetBytes(SenderConnectionID), 0, sizeof(int)); NetworkManager.Instance.SendPacketToClient(ConnectionIDPacket, QosType.Reliable); } break; case NetworkPacketHeader.PlayerReady: { int ReadyPlayerConnectionID = BitConverter.ToInt32(Packet.GetPacketData(), 0); BattleRoyale_GameManager.Instance.PlayerReady(ReadyPlayerConnectionID); } break; case NetworkPacketHeader.StartGame: break; case NetworkPacketHeader.SpawnPlayer: { int PlayerConnectionID = BitConverter.ToInt32(Packet.GetPacketData(), 0); PlayerManager.Instance.SpawnPlayer(PlayerConnectionID); } break; case NetworkPacketHeader.PlayerPosition: { int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); int InputID = BitConverter.ToInt32(Packet.GetPacketData(), 4); Vector3 position = Serializer.DeserializeToVector3(Packet.GetPacketData(), 8); PlayerManager.Instance.GetPlayer(PlayerID).SetPosition(position); } break; case NetworkPacketHeader.ArmDirection: { int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); int InputID = BitConverter.ToInt32(Packet.GetPacketData(), 4); Vector3 ArmDirection = Serializer.DeserializeToVector3(Packet.GetPacketData(), 8); PlayerManager.Instance.GetPlayer(PlayerID).SetArmDirection(ArmDirection); } break; case NetworkPacketHeader.PlayerTransform: { int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); Vector3 position = Serializer.DeserializeToVector3(Packet.GetPacketData(), 4); Vector3 rotation = Serializer.DeserializeToVector3(Packet.GetPacketData(), 16); PlayerManager.Instance.GetPlayer(PlayerID).SetTransform(position, rotation); } break; case NetworkPacketHeader.PlayerUpdate: { int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); int InputID = BitConverter.ToInt32(Packet.GetPacketData(), 4); Vector3 position = Serializer.DeserializeToVector3(Packet.GetPacketData(), 8); Vector3 ForwardVector = Serializer.DeserializeToVector3(Packet.GetPacketData(), 20); Vector3 CurrentArmDir = Serializer.DeserializeToVector3(Packet.GetPacketData(), 32); } break; case NetworkPacketHeader.RagdollPlayer: { int PlayerToRagdollID = BitConverter.ToInt32(Packet.GetPacketData(), 0); PlayerManager.Instance.GetPlayer(PlayerToRagdollID).Ragdoll(); } break; case NetworkPacketHeader.PlayerInputUpdate: { int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); float DeltaTime = BitConverter.ToSingle(Packet.GetPacketData(), 4); int InputID = BitConverter.ToInt32(Packet.GetPacketData(), 8); int AmountOfInputs = BitConverter.ToInt32(Packet.GetPacketData(), 12); PlayerManager.Instance.GetPlayer(PlayerID).ReceiveInputs(Packet.GetPacketData(), AmountOfInputs, InputID, DeltaTime); } break; case NetworkPacketHeader.AddPlayerToRoom: { int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); int RoomIndex = BitConverter.ToInt32(Packet.GetPacketData(), 4); Vector3 PlayerPosition = Serializer.DeserializeToVector3(Packet.GetPacketData(), 8); LevelManager.Instance.GetRoom(RoomIndex).PlayerJoinRoom(PlayerID, PlayerPosition); } break; case NetworkPacketHeader.RemovePlayerFromRoom: { int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); int RoomIndex = BitConverter.ToInt32(Packet.GetPacketData(), 4); LevelManager.Instance.GetRoom(RoomIndex).PlayerLeaveRoom(PlayerID); } break; case NetworkPacketHeader.SpawnPlayerInRoom: { //int PlayerID = BitConverter.ToInt32(Packet.GetPacketData(), 0); //int RoomIndex = BitConverter.ToInt32(Packet.GetPacketData(), 4); //LevelManager.Instance.GetRoom(RoomIndex).PlayerJoinRoom(PlayerID); } break; case NetworkPacketHeader.RequestLevel: { NetworkPacketSender.SendLevelData(SenderConnectionID); } break; case NetworkPacketHeader.LevelData: { LevelManager.Instance.ReadInLevelBytes(Packet.GetPacketData()); } break; case NetworkPacketHeader.RequestRoomData: { int RoomIndex = BitConverter.ToInt32(Packet.GetPacketData(), 0); NetworkPacketSender.SendRoomData(SenderConnectionID, RoomIndex); } break; case NetworkPacketHeader.RoomData: { int RoomIndex = BitConverter.ToInt32(Packet.GetPacketData(), 0); LevelManager.Instance.GetRoom(RoomIndex).ReadInRoomAsBytes(Packet.GetPacketData()); } break; case NetworkPacketHeader.RequestCurrentPlayers: { NetworkPacketSender.SendPlayerData(SenderConnectionID); } break; case NetworkPacketHeader.PlayerData: { PlayerManager.Instance.ReadInPlayersAsBytes(Packet.GetPacketData()); } break; } }