public void StartSession(IP2PAddress address) { if (P2PSession.Instance != null) { P2PSession.Instance.Start(address); } }
public bool Start(IP2PAddress address) { this.StartInternal(); if (P2PTransportLayer.Instance.GetLayerType() == ETransporLayerType.UNet) { P2PAddressUnet p2PAddressUnet = address as P2PAddressUnet; if (p2PAddressUnet.m_IP.Equals("localhost")) { p2PAddressUnet.m_IP = "127.0.0.1"; } else if (p2PAddressUnet.m_IP.IndexOf(":") != -1 && !P2PSession.IsValidIpV6(p2PAddressUnet.m_IP) && P2PLogFilter.logError) { Debug.LogError("Invalid ipv6 address " + p2PAddressUnet.m_IP); } } this.SetGameVisibility(GreenHellGame.Instance.m_Settings.m_GameVisibility); this.m_LocalPeer.SetLocalHostId((short)P2PTransportLayer.Instance.AddHost(P2PSession.s_HostTopology, ref address)); if (this.m_LocalPeer.GetLocalHostId() == P2PPeer.s_InvalidId) { if (P2PLogFilter.logError) { Debug.LogError("StartServer listen failed."); } return(false); } this.m_LocalPeer.m_Address = address; this.m_LocalPeer.SetHostId(this.m_LocalPeer.GetLocalHostId()); if (P2PLogFilter.logDebug) { Debug.Log("P2PSession listen start with id: " + this.GetSessionId()); } this.Status = P2PSession.ESessionStatus.Listening; return(true); }
public void GetConnectionInfo(int connection_id, out IP2PAddress address, out byte error) { address = new P2PAddressUnet(); P2PAddressUnet p2PAddressUnet = (P2PAddressUnet)address; NetworkID networkID; NodeID nodeID; NetworkTransport.GetConnectionInfo((int)P2PSession.Instance.LocalPeer.GetLocalHostId(), connection_id, out p2PAddressUnet.m_IP, out p2PAddressUnet.m_Port, out networkID, out nodeID, out error); }
public static void OnExternalLobbyJoinRequest(IP2PAddress address) { P2PTransportLayer.OnExternalLobbyJoinRequestDel onExternalLobbyJoinRequestEvent = P2PTransportLayer.OnExternalLobbyJoinRequestEvent; if (onExternalLobbyJoinRequestEvent == null) { return; } onExternalLobbyJoinRequestEvent(address); }
public void GetConnectionInfo(int connection_id, out IP2PAddress address, out byte error) { CSteamID connectionSteamId = this.GetConnectionSteamId(connection_id); address = new P2PAddressSteam { m_SteamID = connectionSteamId }; error = ((connectionSteamId == CSteamID.Nil) ? 2 : 0); }
public string GetPlayerDisplayName(IP2PAddress address) { foreach (P2PLobbyMemberInfo p2PLobbyMemberInfo in this.m_LobbyMembers) { if (p2PLobbyMemberInfo.m_Address.Equals(address)) { return(p2PLobbyMemberInfo.m_Name); } } return(SteamFriends.GetFriendPersonaName((address as P2PAddressSteam).m_SteamID)); }
public int ConnectWithSimulator(IP2PAddress address, out byte error, ConnectionSimulatorConfig config) { P2PAddressUnet p2PAddressUnet = address as P2PAddressUnet; if (p2PAddressUnet != null) { return(NetworkTransport.ConnectWithSimulator((int)P2PSession.Instance.LocalPeer.GetLocalHostId(), p2PAddressUnet.m_IP, p2PAddressUnet.m_Port, 0, out error, config)); } Debug.LogError(string.Format("Using invalid IP2PAddress type {0}", address.GetType())); error = 0; return(-1); }
public int AddHost(HostTopology topology, ref IP2PAddress address) { P2PAddressUnet p2PAddressUnet = address as P2PAddressUnet; if (p2PAddressUnet == null) { Debug.LogError(string.Format("Using invalid IP2PAddress type {0}", address.GetType())); return(-1); } if (p2PAddressUnet.m_IP.Empty()) { return(NetworkTransport.AddHost(topology, p2PAddressUnet.m_Port)); } return(NetworkTransport.AddHost(topology, p2PAddressUnet.m_Port, p2PAddressUnet.m_IP)); }
public void Write(IP2PAddress addr) { ETransporLayerType layerType = P2PTransportLayer.Instance.GetLayerType(); if (layerType == ETransporLayerType.UNet) { P2PAddressUnet p2PAddressUnet = addr as P2PAddressUnet; this.Write(p2PAddressUnet.m_IP); this.Write(p2PAddressUnet.m_Port); return; } if (layerType != ETransporLayerType.Steam) { throw new NotImplementedException(); } P2PAddressSteam p2PAddressSteam = addr as P2PAddressSteam; this.Write(p2PAddressSteam.m_SteamID.m_SteamID); }
public void Connect(IP2PAddress address) { this.m_LocalPeer.SetHostId(P2PPeer.s_InvalidId); this.ConnectInternal(address); }
public int AddHostWithSimulator(HostTopology topology, int min_timeout, int max_timeout, ref IP2PAddress address) { P2PAddressUnet p2PAddressUnet = address as P2PAddressUnet; if (p2PAddressUnet != null) { return(NetworkTransport.AddHostWithSimulator(topology, min_timeout, max_timeout, p2PAddressUnet.m_Port)); } Debug.LogError(string.Format("Using invalid IP2PAddress type {0}", address.GetType())); return(-1); }
public string GetPlayerDisplayName(IP2PAddress address) { return(string.Empty); }
public bool IsSameAddress(IP2PAddress addr) { return(this.m_Address.Equals(addr)); }
public int Connect(IP2PAddress address, out byte error) { error = 0; return(-1); }
public int AddHostWithSimulator(HostTopology topology, int min_timeout, int max_timeout, ref IP2PAddress address) { return(this.AddHost(topology, ref address)); }
public int ConnectWithSimulator(IP2PAddress address, out byte error, ConnectionSimulatorConfig config) { return(this.Connect(address, out error)); }
public void JoinLobby(IP2PAddress address) { }
private void ConnectInternal(IP2PAddress address) { this.StartInternal(); this.m_AmIMaster = false; P2PAddressUnet p2PAddressUnet = address as P2PAddressUnet; if (p2PAddressUnet != null) { if (p2PAddressUnet.m_IP.Equals("localhost")) { p2PAddressUnet.m_IP = "127.0.0.1"; } else if (p2PAddressUnet.m_IP.IndexOf(":") != -1 && !P2PSession.IsValidIpV6(p2PAddressUnet.m_IP) && P2PLogFilter.logError) { Debug.LogError("Invalid ipv6 address " + p2PAddressUnet.m_IP); } } int networkConnectionId; if (this.m_UseSimulator) { int num = this.m_SimulatedLatency / 3; if (num < 1) { num = 1; } if (P2PLogFilter.logDebug) { Debug.Log(string.Concat(new object[] { "Connect Using Simulator ", this.m_SimulatedLatency / 3, "/", this.m_SimulatedLatency })); } ConnectionSimulatorConfig config = new ConnectionSimulatorConfig(num, this.m_SimulatedLatency, num, this.m_SimulatedLatency, this.m_PacketLoss); byte b; networkConnectionId = P2PTransportLayer.Instance.ConnectWithSimulator(address, out b, config); } else { byte b; networkConnectionId = P2PTransportLayer.Instance.Connect(address, out b); } P2PConnection p2PConnection = (P2PConnection)Activator.CreateInstance(typeof(P2PConnection)); p2PConnection.SetHandlers(this.m_MessageHandlers); P2PPeer p2PPeer = null; for (int i = 0; i < this.m_PendingPeers.Count; i++) { if (this.m_PendingPeers[i].IsSameAddress(address)) { p2PPeer = this.m_PendingPeers[i]; this.m_PendingPeers.RemoveAt(i); break; } } if (p2PPeer == null) { p2PPeer = new P2PPeer(); p2PPeer.m_Address = address; } if (!this.m_RemotePeersInternal.Contains(p2PPeer)) { this.m_RemotePeersInternal.Add(p2PPeer); } p2PConnection.Initialize(p2PPeer, networkConnectionId, P2PSession.s_HostTopology); this.SetConnectionAtIndex(p2PConnection); if (this.Status == P2PSession.ESessionStatus.Idle) { this.Status = P2PSession.ESessionStatus.Connecting; } }
public int AddHost(HostTopology topology, ref IP2PAddress address) { return(0); }