public Client(SteamSockets transport, string address, SteamSockets.SocketMode socketMode) { if (transport.debug) { Debug.Log($"SteamSockets.Client: Starting"); } if (transport.debug) { Debug.Log($"Creating connection manager ({socketMode})"); } switch (socketMode) { case SteamSockets.SocketMode.P2P: if (transport.debug) { Debug.Log($"Connecting to P2P server steamid {address}"); } SteamId connectSteamId = new SteamId(); connectSteamId.Value = Convert.ToUInt64(address); connectionManager = SteamNetworkingSockets.ConnectRelay <FPConnectionManager>(connectSteamId); break; case SteamSockets.SocketMode.UDP: string[] ipPort = address.Split(':'); NetAddress netAddress = NetAddress.From(ipPort[0], Convert.ToUInt16(ipPort[1])); if (transport.debug) { Debug.Log($"Connecting to UDP server {netAddress}"); } connectionManager = SteamNetworkingSockets.ConnectNormal <FPConnectionManager>(netAddress); break; } connectionManager.transport = transport; if (transport.debug) { Debug.Log($"Connecting: {connectionManager.Connecting} Connected: {connectionManager.Connected}"); } }
public void Disconnect() { connectionManager.Connection.Close(); connectionManager.Close(); connectionManager = null; }