public bool Start(string connectionServerEndPoint) { using (var httpClient = new HttpClient()) { var response = httpClient.SendAsync( new HttpRequestMessage( HttpMethod.Post, $"{connectionServerEndPoint}/player/123/connect") { Content = new StringContent( _jsonSerializer.Serialize( new PostPlayerConnectRequestBody { WorldType = "eden", }), Encoding.UTF8, "application/json") }).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; this._logger.Info($"Received login response: {jsonString}"); //var connectionData = _jsonSerializer.Deserialize<PostPlayerConnectResponseBody>(jsonString); var connectionData = _jsonSerializer.Deserialize_PostPlayerConnectResponseBody(jsonString); this._connection.PlayerId = new PlayerId(connectionData.PlayerId); this._connection.WorldInstanceId = new WorldInstanceId(connectionData.WorldInstancId); this._transport = new ClientUdpPacketTransport( this._logger, this._transportConfig.PacketEncryptor, this._transportConfig, new IPEndPoint(IPAddress.Parse(connectionData.Endpoint), connectionData.Port)); this._connection.PacketEncryptionKey = System.Convert.FromBase64String(connectionData.Key); this._connection.State = GameServerConnection.ConnectionState.PreConnected; // Creates the controllers now that the transport layer has been created. CreateControllers(); _transport.Start(); var thread = new Thread(ProcessIncomingPackets); thread.Start(); this._isRunning = true; this._logger.Info($"Started receiving channel: managedThreadId={thread.ManagedThreadId}"); BeginHandshakeSyn(ConnectionHandshakeKeys.NewSequenceKey()); return(true); } } return(false); }
public ClientSimulationController( ILogger logger, GameServerConnection connection, ClientUdpPacketTransport transport, PacketJitterBuffer jitterBuffer) { this._connection = connection ?? throw new ArgumentNullException(nameof(connection)); this._transport = transport ?? throw new ArgumentNullException(nameof(transport)); this._jitterBuffer = jitterBuffer ?? throw new ArgumentNullException(nameof(jitterBuffer)); this._logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public ClientControlPlaneController(ILogger logger, GameServerConnection connection, ClientUdpPacketTransport transport) { this._connection = connection ?? throw new ArgumentNullException(nameof(connection)); this._transport = transport ?? throw new ArgumentNullException(nameof(transport)); this._logger = logger ?? throw new ArgumentNullException(nameof(logger)); }