예제 #1
0
    void SendRoomNameResponse(NodeIndex clientIndex)
    {
        using (BitWriter writer = _network.GetPooledWriter())
        {
            writer.Normal <byte>((byte)CustomMessageType.RoomNameResponse);

            _sb.Clear();
            _sb.Append(_world.GetRoomName());
            int length = _sb.Length;
            _sb.CopyTo(0, _charBuffer, 0, length);
            writer.ArrayPacked <char>(_charBuffer, length);

            string error;
            if (!_network.SendCustomClient(clientIndex, writer, false, out error))
            {
                Log.Error($"Failed to send RoomNameResponse to client {clientIndex.GetClientIndex()}, error:\n{error}\n");
            }
            else
            {
                Log.Info($"Sent room name: {_world.GetRoomName()} to client: {clientIndex.GetClientIndex()}");
            }
        }
    }