Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Solved] [Unity Transport .0.3], DataStreamWriter isCreated return false and stays what way

Discussion in 'Entity Component System' started by sietse85, Apr 15, 2020.

  1. sietse85

    sietse85

    Joined:
    Feb 22, 2019
    Posts:
    99
    After some time, the writer.isCreated returns false. And it is stuck at that stage.
    The _writer = _client.clientDriver.BeginSend(_client.connection); has no effect to create a valid write buffer.
    What can i do about this?

    Code (CSharp):
    1.   _writer = _client.clientDriver.BeginSend(_client.connection);
    2.            
    3.             for (int i = 0; i < neighbourChunks.Length; i++)
    4.             {
    5.                 if (neighbourChunks[i].x < 0 || neighbourChunks[i].y < 0)
    6.                 {
    7.                     continue;
    8.                 }
    9.  
    10.                 if (neighbourChunks[i].x > ChunkLoaded.GetLength(0) - 1 ||
    11.                     neighbourChunks[i].y > ChunkLoaded.GetLength(1) - 1)
    12.                 {
    13.                     continue;
    14.                 }
    15.  
    16.                 if (!ChunkLoaded[neighbourChunks[i].x, neighbourChunks[i].y])
    17.                 {
    18.                     if (_writer.IsCreated)
    19.                     {
    20.                         GameObject chunk;
    21.                         chunk = Instantiate(_mapChunk);
    22.                         chunk.GetComponent<TerrainChunk>().Generate(neighbourChunks[i].x, neighbourChunks[i].y);
    23.                         ChunkLoaded[neighbourChunks[i].x, neighbourChunks[i].y] = true;
    24.                         _writer.WriteByte((byte) Headers.RequestChunk);
    25.                         _writer.WriteInt(neighbourChunks[i].x);
    26.                         _writer.WriteInt(neighbourChunks[i].y);
    27.                     }
    28.                     else
    29.                     {
    30.                         Debug.Log("No writer");
    31.                     }
    32.                 }
    33.             }
    34.            
    35.             _client.clientDriver.EndSend(_writer);
     
  2. sietse85

    sietse85

    Joined:
    Feb 22, 2019
    Posts:
    99
    Never mind figured out what was the problem. The connection just dropped. I am copying the connection struct but the main one was not getting updates, so the 30's timeout kicked in which caused all kinds of issues of course.

    Bad time to ask questions anyways (Unite)