public override SocketTasks StartClient() { serverUser = new User(new CSteamID(ConnectToSteamID)); SocketTask task = SocketTask.Working; if (SteamNetworking.SendP2PPacket(serverUser.SteamId, new byte[] { 0 }, 1, EP2PSend.k_EP2PSendReliable, (int)InternalChannelType.Connect)) { _p2PSessionConnectFailCallback = Callback <P2PSessionConnectFail_t> .Create((sessionConnectFailInfo) => { OnP2PSessionConnectFail(sessionConnectFailInfo); task.IsDone = true; task.Success = false; task.TransportCode = sessionConnectFailInfo.m_eP2PSessionError; }); } else { P2PSessionConnectFail_t sessionConnectFailInfo = new P2PSessionConnectFail_t() { m_eP2PSessionError = (byte)EP2PSessionError.k_EP2PSessionErrorMax, m_steamIDRemote = serverUser.SteamId }; task.IsDone = true; task.Success = false; task.TransportCode = sessionConnectFailInfo.m_eP2PSessionError; OnP2PSessionConnectFail(sessionConnectFailInfo); } return(task.AsTasks()); }
public override SocketTasks StartClient() { SocketTask task = SocketTask.Working; serverHostId = RelayTransport.AddHost(new HostTopology(GetConfig(), 1), false); serverConnectionId = RelayTransport.Connect(serverHostId, ConnectAddress, ConnectPort, 0, out byte error); NetworkError connectError = (NetworkError)error; switch (connectError) { case NetworkError.Ok: task.Success = true; task.TransportCode = error; task.SocketError = System.Net.Sockets.SocketError.Success; task.IsDone = false; // We want to continue to wait for the successful connect connectTask = task; break; default: task.Success = false; task.TransportCode = error; task.SocketError = System.Net.Sockets.SocketError.SocketError; task.IsDone = true; break; } return(task.AsTasks()); }
public override SocketTasks StartClient() { SocketConfig config = GetConfig(false, NetworkingManager.Singleton.NetworkConfig); socket = new RuffleSocket(config); isConnector = true; if (!socket.Start()) { return(SocketTask.Fault.AsTasks()); } serverConnection = socket.Connect(new IPEndPoint(IPAddress.Parse(ConnectAddress), Port)); if (serverConnection == null) { return(SocketTask.Fault.AsTasks()); } else { connectTask = SocketTask.Working; return(connectTask.AsTasks()); } }
public override SocketTasks StartClient() { serverUser = new User(ConnectToSteamID); SocketTask task = SocketTask.Working; if (SteamNetworking.SendP2PPacket(serverUser.SteamId, new byte[] { 0 }, 1, (int)InternalChannelType.Connect, P2PSend.Reliable)) { clientOnFail = (id, error) => ClientOnP2PSessionConnectFail(id, error, task); SteamNetworking.OnP2PConnectionFailed += clientOnFail; } else { ClientOnP2PSessionConnectFail(serverUser.SteamId, P2PSessionError.Max, task); } return(task.AsTasks()); }
public override SocketTasks StartClient() { Debug.Log("startClient"); if (!EOSSDKComponent.Initialized) { Debug.LogError("EOS not initialized. Client could not be started."); OnCommonDisconnected.Invoke(ServerClientId); return(SocketTask.Fault.AsTasks()); } //StartCoroutine("FetchEpicAccountId"); if (server != null) { Debug.LogError("Transport already running as server!"); //return SocketTask.Fault.AsTasks(); } if (client == null || (client != null && client.Error)) { Debug.Log($"Starting client, target address {RemoteAddress}."); client = Client.CreateClient(this, RemoteAddress); client.Connect(RemoteAddress); client.isConnecting = true; connectTask = SocketTask.Working; return(connectTask.AsTasks()); } else { Debug.LogError("Client already running!"); } return(SocketTask.Done.AsTasks()); }
public override SocketTasks StartClient() { SocketTask task = SocketTask.Working; if (m_HostType != HostType.None) { throw new InvalidOperationException("Already started as " + m_HostType); } m_HostType = HostType.Client; m_NetManager.Start(); NetPeer peer = m_NetManager.Connect(Address, Port, string.Empty); if (peer.Id != 0) { throw new InvalidPacketException("Server peer did not have id 0: " + peer.Id); } m_Peers[(ulong)peer.Id] = peer; return(task.AsTasks()); }
public override SocketTasks StartClient() { SocketTask task = SocketTask.Working; host = new Host(); host.Create(1, MLAPI_CHANNELS.Length + Channels.Count); Address address = new Address(); address.Port = Port; address.SetHost(Address); Peer serverPeer = host.Connect(address, MLAPI_CHANNELS.Length + Channels.Count); serverPeer.PingInterval(PingInterval); serverPeer.Timeout(TimeoutLimit, TimeoutMinimum, TimeoutMaximum); serverPeerId = serverPeer.ID; connectTask = task; return(task.AsTasks()); }
public static SocketTasksAwaiter GetAwaiter(this SocketTask socket) => new SocketTasksAwaiter(socket.AsTasks());